From af70ae5f225d1e1df1dc2f2b09cc8501ffa3a666 Mon Sep 17 00:00:00 2001 From: Hannah Date: Tue, 27 Jan 2026 14:05:13 -0800 Subject: [PATCH 1/3] screenreader working for guide --- src/oceans/components/common/Guide.jsx | 43 ++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/oceans/components/common/Guide.jsx b/src/oceans/components/common/Guide.jsx index f17b8ffc..f21f5a93 100644 --- a/src/oceans/components/common/Guide.jsx +++ b/src/oceans/components/common/Guide.jsx @@ -29,11 +29,30 @@ export const stopTypingSounds = () => { }; let UnwrappedGuide = class Guide extends React.Component { + componentDidUpdate(prevProps, prevState) { + // Focus the dialog on guide change, but do not trap focus + const currentGuide = guide.getCurrentGuide(); + if ( + currentGuide && + this.guideDialogRef && + this.guideDialogRef.current && + document.activeElement !== this.guideDialogRef.current + ) { + this.guideDialogRef.current.focus(); + } + } onTypingDone() { clearInterval(getState().guideTypingTimer); setState({guideShowing: true, guideTypingTimer: undefined}); } + onGuideKeyDown = (e) => { + if (e.key === ' ' || e.key === 'Enter' || e.key === 'Spacebar') { + e.preventDefault(); + this.onGuideClick(); + } + }; + onGuideClick = () => { const state = getState(); const currentGuide = guide.getCurrentGuide(); @@ -142,6 +161,11 @@ let UnwrappedGuide = class Guide extends React.Component { !currentGuide.noDimBackground && currentGuide.style !== 'Info'; + // Ref for focus management + if (!this.guideDialogRef) { + this.guideDialogRef = React.createRef(); + } + return (
{currentGuide && currentGuide.image && ( @@ -157,9 +181,16 @@ let UnwrappedGuide = class Guide extends React.Component { key={currentGuide.id} style={guideBgStyle} onClick={this.onGuideClick} + onKeyDown={this.onGuideKeyDown} + tabIndex={0} + role="button" + aria-label={I18n.t('continue')} id="uitest-dismiss-guide" >
{currentGuide.style === 'Info' && ( -
+
{I18n.t('didYouKnow')}
)} -
+ + {/* Visually hidden aria-live region for screen readers */} +
+ {currentGuide.textFn(getState())} +
+ {/* Visible Typist animation for sighted users */} +