-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Converge suggested actions into live region twin and add roving tab index #4314
Merged
compulim
merged 17 commits into
microsoft:main
from
compulim:fix-a11y-suggested-actions
Jun 16, 2022
Merged
Converge suggested actions into live region twin and add roving tab index #4314
compulim
merged 17 commits into
microsoft:main
from
compulim:fix-a11y-suggested-actions
Jun 16, 2022
Conversation
This file contains 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
compulim
requested review from
a-b-r-o-w-n,
cwhitten,
srinaath,
tdurnford,
tonyanziano and
beyackle
as code owners
June 16, 2022 17:40
compulim
commented
Jun 16, 2022
compulim
commented
Jun 16, 2022
tdurnford
previously approved these changes
Jun 16, 2022
packages/component/src/LiveRegion/private/LiveRegionAttachments.tsx
Outdated
Show resolved
Hide resolved
tdurnford
approved these changes
Jun 16, 2022
tdurnford
approved these changes
Jun 16, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
role="toolbar"
and uses roving tab index for multiple suggested actionDescription
We have multiple live regions in Web Chat. Since browser isn't great at handling multiple of them with simultaneously updates. To workaround browser issues, we need to consolidate all live regions.
Suggested actions container is an element with
aria-live="polite"
androle="status"
. Both defines the liveliness for this container. We are removing both tags. Then, use the chat history live region twin to narrate the suggested actions.As suggested actions container is no longer a live region, it can be unmounted when there are no suggested actions. Thus, we no longer need to narrate "Suggested actions container: Is empty."
Design
Consolidating live regions
For #4296, the issue is likely because both chat history live region and suggested actions live region are being updated at the same time. If they are updated at a slightly different time, browser may interrupt the earlier update and favor the latter update. This means either one of the live regions could skipped by the screen reader.
We are removing live region (
aria-live="polite"
androle="status"
) from suggested actions. Instead, using the chat history live region twin to read the suggested actions (through the<LiveRegionSuggestedActions>
).This will likely reduce browser issues around "suggested actions are not narrated" as no more than one live region will be updated at the same time.
Removing "is empty" narration from the suggested action container
As the suggested actions container is no longer a live region, it does not need to persist on the screen (the basic requirement of live region is the container must always appear in the DOM tree). Thus, it should not narrate "Suggested actions container: Is empty".
Updating role of suggested actions
Also, as suggested actions are all buttons next to each other. The
role="toolbar"
is a better fit for this type of UI. To fulfill the accessibility requirement ofrole="toolbar"
, we are implementing roving tab index and end-users will navigate across suggested action buttons using navigational keys (left/right for carousel/flow layout, up/down for stacked layout).Since we are using roving tab index for the suggested actions, we will have 2 layers of focus: focus on the container and focus on each individual button. We added style options to show both focii (solid/wide for container, dashed/thin for button), similar to chat history.
<RovingTabIndexProvider>
This provider will provide roving tab index functionality to all components.
We tried 2 ways to implement this component:
useTabIndex(index: number): [number]
to return atabindex
value of either0
or-1
useFocusHandler(index: number): () => void
anduseBlurHandler(index: number): () => void
to return an event listener that should hook to the elementuseItemRef(ref: RefObject<HTMLElement>, index: number)
to automatically attachfocus
/blur
handler and patchtabindex
attribute via DOMWe opted for the latter approach as it deemed more lightweight on the API side, despite, it is hacking React-controlled component via
setAttribute()
. We think this is reasonable balance.Specific Changes
suggestedActionsVisualKeyboardIndicatorColor
suggestedActionsVisualKeyboardIndicatorStyle
suggestedActionsVisualKeyboardIndicatorWidth
useDateFormatter.ts
<LiveRegionActivity>
(entrypoint),<LiveRegionAttachments>
and<LiveRegionSuggestedActions>
<ScreenReaderActivity>
to<LiveRegionActivity>
, this component is used by live region twin only<RovingTabIndexProvider>
anduseItemRef()
hook to bring the roving tab index functionality to all componentstext
field (which will not be rendered in the visible chat history)useFocusWithin
for polyfilling browsers that does not support:focus-within
pseudo classserve
updated its default to 3000 insteadCHANGELOG.md
Review Checklist
z-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)