Fix escape key behavior for embedded and standalone month pickers
This change fixes a couple of related issues about keyboard input the standalone month picker control and the month switcher menu embedded in other calendar picker controls. - The standalone month picker didn't close when the user hits Escape. The code for this was just missing (the month picker was built by reusing the YearListView for embedded month switcher menus embedded in other calendar popups, for which Escape is handled by the outer control). I've added the code to handle Escape. - I noticed that the escape was also not working to dismiss the month switcher menu when opened in a datetime-local. One problem with fixing this was was that the top-level DateTimeLocalPicker had no way to distinguish whether a EventTypeYearListViewDidHide was triggered by an Escape or Enter, where Escape would mean that the display should go back to the previously selected month. I reworked how the YearListView dispatches events to make this work; it now sends EventTypeYearListViewDidSelectMonth to indicate that a month was chosen and that the control should be dismissed, sends EventTypeYearListViewDidHide to indicate that the month switcher should be dismissed without changes, and sends nothing when the user arrow-key-navigates between months. One side-effect is that the month displayed on the month switcher button no longer updates as the user navigates between months, but this is consistent with the no-live-update behavior of our standalone month/week/date pickers. If we switch those to live-update, we should consider switching this behavior correspondingly. These changes are gated behind isFormControlsRefresh so that the old picker keeps the old behavior. - While working on the above I also noticed that clicking the body of a datetime-local or or on the month switcher or previous/next month buttons would cause the popup's value to be pushed to the in-page control. I fixed this by getting rid of the approach where parts of the calendar control suppress events so that they are not seen by the top level control, and instead equip the top-level DateTimePicker class to filter the keyboard and click events it receives so that it only acts on the ones with the relevant event.targets (time and date cells and the Today button). Tests are included for all of the above. Bug: 1026489 Change-Id: I0e66dae98d891c79ea7e1fe2821c948eb9aef499 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003431Reviewed-by:Ionel Popescu <iopopesc@microsoft.com> Reviewed-by:
Mason Freed <masonfreed@chromium.org> Commit-Queue: Dan Clark <daniec@microsoft.com> Cr-Commit-Position: refs/heads/master@{#733053}
Showing
Please register or sign in to comment