-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(material/datepicker): restore focus after closing animation #25567
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
fix(material/datepicker): restore focus after closing animation #25567
Conversation
Currently the datepicker restores focus when the closing sequence starts, but in some cases that can cause focus to be lost. When the calendar view changes, we delay moving focus for a while in order to work around a VoiceOver issue. This means that if a closing sequence is kicked off while there's an in-progress view change, focus may end up being restored, then moved back into the calendar which then gets destroyed. This can be seen in the "Datepicker emulating a Year and month picker" example. These changes resolve the issue by moving the focus restoration all the way to the end of the closing sequence. Fixes angular#25564.
// Since we restore focus after the exit animation, we have to check that | ||
// the user didn't move focus themselves inside the `close` handler. | ||
if ( | ||
canRestoreFocus && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't write a test for this, because there are several timeouts and animations happening at the same time and flushing one of them flushes everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Currently the datepicker restores focus when the closing sequence starts, but in some cases that can cause focus to be lost. When the calendar view changes, we delay moving focus for a while in order to work around a VoiceOver issue. This means that if a closing sequence is kicked off while there's an in-progress view change, focus may end up being restored, then moved back into the calendar which then gets destroyed. This can be seen in the "Datepicker emulating a Year and month picker" example. These changes resolve the issue by moving the focus restoration all the way to the end of the closing sequence. Fixes #25564. (cherry picked from commit 814ba1b)
…lar#25567) Currently the datepicker restores focus when the closing sequence starts, but in some cases that can cause focus to be lost. When the calendar view changes, we delay moving focus for a while in order to work around a VoiceOver issue. This means that if a closing sequence is kicked off while there's an in-progress view change, focus may end up being restored, then moved back into the calendar which then gets destroyed. This can be seen in the "Datepicker emulating a Year and month picker" example. These changes resolve the issue by moving the focus restoration all the way to the end of the closing sequence. Fixes angular#25564.
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@angular/cdk](https://github.com/angular/components) | dependencies | patch | [`14.2.1` -> `14.2.2`](https://renovatebot.com/diffs/npm/@angular%2fcdk/14.2.1/14.2.2) | | [@angular/material](https://github.com/angular/components) | dependencies | patch | [`14.2.1` -> `14.2.2`](https://renovatebot.com/diffs/npm/@angular%2fmaterial/14.2.1/14.2.2) | --- ### Release Notes <details> <summary>angular/components</summary> ### [`v14.2.2`](https://github.com/angular/components/blob/HEAD/CHANGELOG.md#​1422-cytoplasm-salmon-2022-09-14) [Compare Source](angular/components@14.2.1...14.2.2) ##### cdk | Commit | Type | Description | | -- | -- | -- | | [6275f9d41f](angular/components@6275f9d) | fix | **a11y:** account for Windows 11 high contrast themes in detector ([#​25624](angular/components#25624)) | | [eb5f79bb7b](angular/components@eb5f79b) | fix | **listbox:** error with multiple preselected values ([#​25621](angular/components#25621)) | | [65af24ee53](angular/components@65af24e) | fix | **menu:** don't prevent default enter and space actions ([#​25591](angular/components#25591)) | ##### material | Commit | Type | Description | | -- | -- | -- | | [b3e35f3be4](angular/components@b3e35f3) | fix | **datepicker:** restore focus after closing animation ([#​25567](angular/components#25567)) | #### Special Thanks Kristiyan Kostadinov and Paul Gschwendtner <!-- CHANGELOG SPLIT MARKER --> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xOTUuMyIsInVwZGF0ZWRJblZlciI6IjMyLjE5Ni4wIn0=--> Co-authored-by: cabr2-bot <[email protected]> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1547 Reviewed-by: Epsilon_02 <[email protected]> Co-authored-by: Calciumdibromid Bot <[email protected]> Co-committed-by: Calciumdibromid Bot <[email protected]>
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Currently the datepicker restores focus when the closing sequence starts, but in some cases that can cause focus to be lost. When the calendar view changes, we delay moving focus for a while in order to work around a VoiceOver issue. This means that if a closing sequence is kicked off while there's an in-progress view change, focus may end up being restored, then moved back into the calendar which then gets destroyed. This can be seen in the "Datepicker emulating a Year and month picker" example.
These changes resolve the issue by moving the focus restoration all the way to the end of the closing sequence.
Fixes #25564.