Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update date components #405

Merged
merged 8 commits into from
Nov 14, 2024
Merged

Conversation

AnnMarieW
Copy link
Collaborator

@AnnMarieW AnnMarieW commented Nov 9, 2024

Closes #403

  • add debounce=True to DatePicker
  • add missing highlightToday prop
  • handle clearable DateInput when debounce=True
  • added test

Notes on adding debounce to the DatePicker

The input field in DatePicker behaves differently from DateInput in Mantine:

  • In DateInput, users can type a date directly into the Input field (or select from a calendar). Pressing Enter will make the input lose focus, updating the value.
  • In DatePicker users cannot type directly into the input field. Pressing Enter or clicking on the field opens the calendar, shifting the focus to it. The value is only updated by selecting dates from the calendar. The n_submit prop (counter for enter key pressed) has limited use here and is being kept only for legacy reasons (remove in a future major release?).
  • onBlur Behavior:
    • In DateInput, the onBlur counter n_blur is useful for detecting when a user finishes typing or selecting a date.
    • In DatePicker, n_blur isn’t useful because the focus shifts from the input to the calendar triggering the counter. The n_blur counter doesn't indicate that the user has finished entering an input, so it is not included in this component.

@AnnMarieW AnnMarieW marked this pull request as ready for review November 10, 2024 20:07
Comment on lines +114 to +116
# initially no change
time.sleep(.5)
dash_duo.wait_for_text_to_equal("#out-2000", "None", timeout=1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add the nice with pytest.raises pattern you used in #407

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃

@AnnMarieW AnnMarieW merged commit 6dcf035 into snehilvj:master Nov 14, 2024
1 check passed
@AnnMarieW AnnMarieW deleted the update-date-components branch November 14, 2024 13:18
@Ferreira-B
Copy link

Great job on the update!
I may have encountered a possible bug.

I have a datePickerInput with type="range" and debouce=True.
This datePickerInput is acting as Input of a callback.

Now, the callback should be triggered as I click the second date on the datePickerInput (as this action also closes the date picker). The problem is that the callback is not triggered when the date picker closes, but only after I click anywhere on the page.

I don't know if this is the expected behaviour, but I thought I might report it.

@AnnMarieW
Copy link
Collaborator Author

Hi @Ferreira-B
Yes, this is expected behavior. With debounce=True, the callback is triggered when the input loses focus. With this component the input stays focused after the dropdown is closed.

For your use-case, you could try setting debounce=False. The callback will trigger twice, but you could check that the date value has both a start and end date.

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.

[Feature Request] Add new debounce prop to DatePicker
3 participants