[core] feat(Overlay): set aria-live attribute for a11y #4900
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.
Fixes #4813
Checklist
Changes proposed in this pull request:
Set aria-live on Overlay
This allows screen readers to read content in Tooltips, Popovers,
Dialogs, and Overlays when they are opened.
Not using aria-describedby because the Overlay content is typically
added to the DOM after interaction with some other element, leaving
screen readers unable to consistently see the content in time. Setting
aria-live on the Overlay works because it remains mounted after the
initial open. VoiceOver is also able to read the content on initial
open (did not test with other screen readers).
Reviewers should focus on:
This behavior change is not limited to Tooltips/Tooltips2 but affects all consumers of the Overlay component. When using a screen reader, Overlay contents will be read on open. I think this is desirable, because otherwise non-keyboard-focusable elements in Overlay contents, namely large blocks of text, will not get read.
Screenshot
Initial attempt with
aria-describedby
and setting contentid
results in inconsistent reading of tooltipFirst focus over "Or, hover of this whole line" does not read the tooltip, but a second focus does.
(In this PR) Using
aria-live="polite"
Works consistently with or without portals. The tooltips on the last line have
usePortal
set tofalse
.In Chrome:
In FF: