Fix ContextualMenuItemButton's secondary text never read by screen-reader#6670
Merged
KevinTCoughlin merged 5 commits intomicrosoft:masterfrom Oct 12, 2018
Merged
Conversation
Member
Author
|
Note to self to look at screenshot / unit test coverage here. It may already exist, but I want to make sure we don't regress this. |
joschect
approved these changes
Oct 12, 2018
18 tasks
Member
Author
|
Might also be worth mentioning that a workaround exists in |
Member
Author
|
Added some unit tests in an attempt to give us some coverage with a link to this PR for context. Unit tests added:
I couldn't find existing tests for the above scenarios. Let me know if I missed them, happy to not have dupes. |
mikewheaton
approved these changes
Oct 12, 2018
natalieethell
approved these changes
Oct 12, 2018
Contributor
|
🎉 Handy Links: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request checklist
$ npm run changeDescription of changes
Overview
We received an accessibility report in #6360:
After debugging, I found that this is because we set an
aria-labelonContextualMenuButtonequal to eitherprops.ariaLabeloritem.text || item.name || ''. The item's secondary text is never included in thataria-labelasitem.secondaryTextand therefore never read.The Change
Initially, I thought the fix was to either conditionally concatenate primary and secondary text to produce
aria-labelor replacearia-labelwitharia-labelledbyreferencing both primary and secondary text nodes via unique IDs. The spec recommendsaria-labelledbyfor multiple nodes with text visible.However, I found that I could remove the usage of
aria-labelcompletely (unless specified by the user via props) and the bug was fixed. Both primary and secondary text were then announced by Narrator because they are present in the DOM as child text nodes. See Narrator Buddy Output.Conclusion
I'm recommending this change, because it seems to be backwards compatible for devs that are already supplying their own
ariaLabelor relying on text contentsitem.textoritem.namebe read by assistive technology.I believe that the most likely usage of
ariaLabelin aContextualMenuItemButtonis when the item's text is unclear such as"X". In this case, the existing code's default value will be"X"foraria-labeland not any more useful. This would require a developer to supply their ownariaLabelvalue anyway.Narrator Buddy Output
Before
Default ContextualMenu Example
ContextualMenu w/ Secondary Text Example
After
Default ContextualMenu Example
ContextualMenu w/ Secondary Text Example
Focus areas to test
References
Microsoft Reviewers: Open in CodeFlow