feat: add reusable announceToScreenReader helper and refactor block.js (#6608)#7764
Conversation
5b5c1fc to
1b49d67
Compare
|
@walterbender , the code for the aria-live helper and block.js refactor is ready. Note: The CI is currently failing on pitchstaircase.test.js and musickeyboard.test.js, but I verified this PR does not touch those files. It appears those tests are currently failing on master. |
|
Are there any other places we should be using this utility? |
|
@walterbender Yep, A few spots still need it: will clean up activity.js and update blocks.js in a quick follow-up once #7753 merges! |
Description
Extracts the
aria-liveregion creation logic into a reusableannounceToScreenReaderhelper function injs/utils/utils.js. Refactors the drag announcement injs/block.jsto use this new helper instead of an inline IIFE.This centralizes screen reader announcements, avoiding duplicate DOM creation logic and making it easier to trigger silent assistive announcements across the rest of the codebase.
Related Issue
Part of #6608
Category
Type of Change
Testing Performed
localhost:3000, enabled VoiceOver on macOS.mbA11yLiveRegionis correctly lazy-loaded into the DOM on the first call and reused for subsequent announcements.npx prettier --check js/block.js js/utils/utils.js— clean.PR Checklist