-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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/menu): focus the first item when opening menu on iOS VoiceOver #24733
Conversation
Deployed dev-app to: https://ng-comp-dev--pr-24733-3df39ff52d92ef2afd89186d51460fa6-how8d5o9.web.app |
06fa24d
to
2ce0153
Compare
f1a439c
to
4b508e7
Compare
4b508e7
to
0396c73
Compare
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
Hmm, it seems like this doesn't work since the menu emits the "opened" event before calling I'll look into another solution for this and send out a new PR when I have it working. |
Re-opening because because there is no requirement when focus is called, just that it has to be called some time after |
src/material/menu/menu.spec.ts
Outdated
@@ -1147,6 +1147,7 @@ describe('MatMenu', () => { | |||
fixture.detectChanges(); | |||
|
|||
fixture.componentInstance.trigger.menuOpened.subscribe(() => { | |||
flush(); |
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.
@crisbeto I'm confused about this test. I understand that for the openMenu
method, there is no requirement on when the first element of the list is focused. It has to be focused in some time after calling openMenu.
For the menuOpened
event, is there a requirement that the first element must be focused by the time the menuOpened
event fires?
To avoid a race condition with the _focusFirstItem
method, this test adds a flush. In application code, the developer would have to wait for onStable
or do a setTimeout
. There is still a way for developers to move focus inside the open
event callback, but not at the time the open
event is fired.
Does this PR meet the requirements for the behavior of menuOpened
?
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.
This is checking that we don't override the consumer's focus, if they moved it into the menu themselves before we tried to focus the first item. That's why I was proposing the if (!menu.contains(document.activeElement)
check.
0396c73
to
708cb12
Compare
Hi @crisbeto , I fixed this PR to use the |
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
…ceOver When opening the menu using the iOS VoiceOver screen reader, focus the first item in the menu. Previously, the first menu item would focus on other screen readers like desktop VoiceOver but not with iOS VoiceOver. Waiting until `onStable` seems to fix this. Fixes angular#24735
caretaker: please approve this again. Since @crisbeto approved it, I made the fix for this comment.
|
…ceOver (#24733) When opening the menu using the iOS VoiceOver screen reader, focus the first item in the menu. Previously, the first menu item would focus on other screen readers like desktop VoiceOver but not with iOS VoiceOver. Waiting until `onStable` seems to fix this. Fixes #24735 (cherry picked from commit f76103d)
…ceOver (#24733) When opening the menu using the iOS VoiceOver screen reader, focus the first item in the menu. Previously, the first menu item would focus on other screen readers like desktop VoiceOver but not with iOS VoiceOver. Waiting until `onStable` seems to fix this. Fixes #24735 (cherry picked from commit f76103d)
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@angular/cdk](https://github.com/angular/components) | dependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fcdk/13.3.6/13.3.7) | | [@angular/material](https://github.com/angular/components) | dependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fmaterial/13.3.6/13.3.7) | --- ### Release Notes <details> <summary>angular/components</summary> ### [`v13.3.7`](https://github.com/angular/components/blob/HEAD/CHANGELOG.md#​1337-chiffon-carambola-2022-05-11) [Compare Source](angular/components@13.3.6...13.3.7) ##### material | Commit | Type | Description | | -- | -- | -- | | [0bede63d33](angular/components@0bede63) | fix | **datepicker:** add ability to have numeric zero value in input ([#​24813](angular/components#24813)) | | [7a122f7f03](angular/components@7a122f7) | fix | **expansion:** inconsistent spacing for anchor buttons ([#​24882](angular/components#24882)) | | [e486ed93e4](angular/components@e486ed9) | fix | **menu:** focus the first item when opening menu on iOS VoiceOver ([#​24733](angular/components#24733)) | #### Special Thanks Dmytro Prokhorov, Kristiyan Kostadinov and Zach Arend <!-- CHANGELOG SPLIT MARKER --> </details> --- ### Configuration 📅 **Schedule**: 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). Co-authored-by: cabr2-bot <[email protected]> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1349 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. |
When opening the menu using the iOS VoiceOver screen reader, focus the first item in the menu.
Previously, the first menu item would focus on other screen readers like desktop VoiceOver but
not with iOS VoiceOver.
Waiting until
onStable
seems to fix this.Fixes #24735