Skip to content

Conversation

LeticiaBN
Copy link

Summary

Fixes #3385 by adding support for 'time' and 'datetime-local' input types to the dcc.Input component's PropTypes definition.

Problem

As reported in #3385, when creating a valid dcc.Input with time-based input types:

dcc.Input(id='time-input', type='time', step=1, value='00:00:00')
dcc.Input(id='datetime-input', type='datetime-local', step=1, value='2023-01-01T00:00:00')

PyCharm showed type warnings:

Expected type 'Literal["text", "number", "password", "email", "range", "search", "tel", "url", "hidden"] | None', got 'Literal['time']' instead

Root Cause

The PropTypes.oneOf array in components/dash-core-components/src/components/Input.react.js was missing these two HTML5 input types, even though they have wide modern browser support.

Solution

Organized Commits:

Following the contributor guidelines, changes are organized in logical commits:

  1. Add support for 'time' and 'datetime-local' input types (a31ea469)

    • Updated PropTypes in Input.react.js to include missing input types
  2. Update integration tests for new input types (6b056ea9)

    • Enhanced existing test coverage to include new input types
    • Added proper test values for time and datetime inputs
  3. Add comprehensive tests for time and datetime-local inputs (af006f02)

    • Created dedicated test file for complete coverage
    • Tests for debounce, constraints, and callback functionality

Changes Made:

  • Input.react.js: Added 'time' and 'datetime-local' to PropTypes.oneOf array
  • test_input_basics.py: Updated ALLOWED_TYPES and enhanced test logic
  • test_time_datetime_inputs.py: New comprehensive test suite

Contributor Checklist

  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

- Update PropTypes in Input.react.js to include 'time' and 'datetime-local'
- These input types have wide browser compatibility and are commonly requested
- Fixes PyCharm type warnings when using these input types with dcc.Input

Closes plotly#3385
- Add 'time' and 'datetime-local' to ALLOWED_TYPES in test_input_basics.py
- Add proper test values for time and datetime inputs
- Enhance test logic to handle time-specific input validation
- Ensures existing test coverage includes the new input types
- Create dedicated test file for new input type functionality
- Test time input with proper time values and callbacks
- Test datetime-local input with ISO datetime strings
- Test debounce functionality with time inputs
- Test min/max constraints with datetime-local inputs
- Provides full test coverage for the new input types
- Remove unused pytest import
- Clean up trailing whitespace
- Code now rated 10.00/10 by pylint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] dcc.Input types don't support time and datetime-local
1 participant