Repository navigation
fix(settings): render Banner content after mount for screen readers - #21609
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Because: - Screen readers reliably announce only changes to a live region that already exists. - The Banner inserted its live region with its text, so the text was often not announced. This commit: - Adds a `ready` state to Banner, set by one useEffect after mount. - Renders the live region first with only id, role, aria-live and tabIndex. - Adds className, onAnimationEnd and children to the same node after the effect. - Adds a MutationObserver test for the status and alert regions. - Changes five consumer specs from getByText to await findByText. Closes FXA-10912
Because
role="status"orrole="alert"element with its text, so the text was often not announced.This pull request
readystate toBanner/index.tsx. OneuseEffectsets it after mount.divbefore and after the effect, with onlyid,role,aria-liveandtabIndexon the first render.className,onAnimationEndand children to that node.Banner/index.test.tsxfor thestatus(success) andalert(error) regions. It checks that the region is inserted first and its children are added in a later record.getByTexttoawait findByText. Banner text now appears one render after a state update outsideact. Only the expectations change.Risk
Risk: Medium (the worst of the three below)
Issue that this pull request solves
Closes: FXA-10912
Checklist
Put an
xin the boxes that applyHow to review (Optional)
Banner/index.tsxand the newlive regiontest.Banner/index.tsx,Banner/index.test.tsx, then the five consumer specs.Screenshots (Optional)
None. The rendered output after mount does not change.
Other information (Optional)
Not verified: screen reader behavior (NVDA with Firefox, VoiceOver with Safari). The new test checks DOM order only, not announcement. It needs a manual check after merge on "Skip the password next time?" and on one error banner.
One reviewer call: the change uses an effect, not
setTimeout, as the ticket requires. Is that enough for the event-handler case above?Tests:
/fxa-verify --run): plannedfxa-settingsunit tests, lint, Prettier andtsc./fxa-verify --run): functionalresetPassword.spec.ts, "click resend" (status banner) and "enter unknown email" (alert banner), on the local stack.fxa-settingsspecs related to Banner (1942 tests)./fxa-verify --revertshowed that the new test fails without the fix and passes with it.Merge Confidence: 4/5
Bannernow mounts its status or alert live region before adding its classes, animation handler, and content. This lets assistive technology observe the region before its content appears. AMutationObservertest checks insertion order for success and error banners. Consumer tests now wait for banner text to appear.The change affects banner rendering and related tests. The supplied context reports passing unit tests, lint, formatting, type checks, and selected functional checks. Screen reader behavior was not verified, and manual checks remain outstanding.