Add aria-labelledby and move button up #4609
Merged
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.
Changelog Entry
Fixed
aria-labelledby
of the dialog and close button should be the first element of the header, by @compulim in PR #4609Description
We should have
aria-label
oraria-labelledby
for the dialog header.We should put close button (
<button>
) before the dialog header (<h2>
). So, when the end-user press DOWN arrow key from the close button, screen reader would narrate "Keyboard controls".Design
Assume the screen reader cursor lands on the close button thru TAB, when the user press DOWN to instruct the screen reader to read the content (of the dialog), the user expects the screen reader to narrate the title of the dialog.
This means, close button would need to locate in front of the
<h2>
.However, when the screen reader cursor lands on the close button from the transcript (or out of page), since the button resides inside the dialog, screen reader will narrate landmark role as well. Screen reader will narrate "keyboard controls dialog banner header close button". Then, when DOWN is pressed, it will narrate "heading level 2 keyboard controls".
I think both narration design is compliant to ARIA. This is just matter of taste.
The following video shows accessibility experience with this pull request.
2023-01-11.Web.Chat.Keyboard.Help.Screen.Banner.Header.mp4
In the future, we could consider using
<dialog>
/HTMLDialogElement
to host the dialog. This needs more investigation.Specific Changes
aria-labelledby
to<div role="dialog">
and points it to<h2>
<button>
inside the<header>
container and before the<h2>
CHANGELOG.md
Review Checklist
Browser and platform compatibilities reviewedCSS styles reviewed (minimal rules, noz-index
)Documents reviewed (docs, samples, live demo)Internationalization reviewed (strings, unit formatting)package.json
andpackage-lock.json
reviewedSecurity reviewed (no data URIs, check for nonce leak)