-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
DateTimePicker: Click on date causes popover to close automatically #24206
Comments
@pablinos and I can both reproduce this issue. We explored adding a check for if gutenberg/packages/components/src/dropdown/index.js Lines 65 to 72 in 1f62ff8
But it didn't seem to receive any outside events and close when it should (e.g. when editing the post title). Since this is reproducible on react-dates storybook, it’s possible this is a bug that needs to be fixed upstream. This react-dates discussion suggests that @enriquesanchez Did you see a quick solution to this one? Are we missing something obvious? |
Hi @allilevine! I didn't, sorry. I initially thought this would be a |
As noted in #27222, clicking on the AM/PM toggle also causes the popover to close. |
We're encountering problems on a client site with the AM/PM toggles as well, setting the hour then changing from AM to PM changes the time selected, but when the popover containing the component is hidden it the date reverts back to AM |
I'm taking a look at this issue again and I'm able to reproduce both these issues. It seems like it's specifically changing the hour that switches the toggle back to AM. |
Do we want to move the AM/PM bug to a new ticket? I spent 10 minutes to do a quick look these are the next avenues of investigation I would take:
|
I've created #29720 to track the AM/PM bug |
Describe the bug
I'm trying to use the
DateTimePicker
component inside of aDropdown
component with other settings. Unfortunately, clicking on a date in the picker automatically closes the popover. This prevents the user to change other settings unless they reopen the popover.The same happens with the default date picker to schedule a post. It might be the case that this is intentional but it only "works" as is due to the way how the
DayPickerSingleDateController
andPopover
components are working.To reproduce
Steps to reproduce the behavior:
See also https://wordpress.slack.com/archives/C02QB2JS7/p1592578807492400 for a gif.
Expected behavior
The popover stays open so I can review the selected data in case I clicked on a wrong date. Or, when used in a custom component,
DateTimePicker
should have a setting to prevent this behaviour.Additional context
This happens because when clicked on a date in
DayPickerSingleDateController
,document.activeElement
it set to thebody
element.PostSchedule
withDateTimePicker
is used in aDropdown
component which sets theonFocusOutside
prop with a function that checks if thedocument.activeElement
is part of the container ref. Since thebody
element fails that check so the popover closes.The
document.activeElement
issue can also be reproduced on react-dates' storybook: https://airbnb.io/react-dates/iframe.html?id=daypickersingledatecontroller--defaultThe text was updated successfully, but these errors were encountered: