feat: aria live region for announcements by mikeharv · Pull Request #9653 · RaspberryPiFoundation/blockly
This adds an aria live region for announcing updates on Blockly. This was partially backported out of the screen-reader branch.
The basics
API verified by testing announcement of toast changes via uncommitted code.
The details
Resolves #9632
Fixes
Proposed Changes
During inject(), we will create a displayed-but-user-invisible <div/> with id blocklyAriaAnnounce which is configured as an aria live region with passive priority. Other parts of Blockly will be able to call announceDynamicAriaState with text to add to this region to be read by assistive technologies. An asynchronous timeout is used to manage replacing outdated pending announcements with the latest update.
Reason for Changes
This will give us a centralized place to announce dynamic state changes and information that cannot otherwise be conveyed.
Test Coverage
Added ARIA live region tests covering initialization, accessibility attributes, delayed announcements, repeated message handling, last-write-wins behavior, and delayed updates to role and assertiveness to prevent regressions.
Documentation
N/A