feat: Screenreader announcements for move mode#9731
Open
mikeharv wants to merge 3 commits intoRaspberryPiFoundation:v13from
Open
feat: Screenreader announcements for move mode#9731mikeharv wants to merge 3 commits intoRaspberryPiFoundation:v13from
mikeharv wants to merge 3 commits intoRaspberryPiFoundation:v13from
Conversation
This file contains hidden or 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
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.
The basics
The details
Resolves
Fixes #9686
Proposed Changes
This PR introduces ARIA live region announcements for moving blocks (both keyboard-driven move mode and standard mouse/pointer drags).
Key changes include:
computeMoveLabelto generate more descriptive and context-aware move announcements.before,after,inside,around) based on connection types.if,else if,elsestatement inputs)=)text_joinblocks)BlockSvg.getStackBlocksCountLabelto announce stack size when moving multiple connected "stack blocks".BlockDragStrategy.Field.getAriaValueto usegetTextinstead ofgetValue, improving readout of some custom fields.getParentInputLabelto ignore parent blocks if they are the insertion marker for the moving blockgetInputLabelsto use a newInput.getLabelmethod which now also correctly ignore insertion markers.If a block is moving without a candidate connection we will simply announce
moving [block label] on workspace. It was decided that omitting cardinal directions is beneficial here as the user likely knows which arrow keys they have pressed (or which way they are dragging).If a user cancels a movement, this is also announced. There is not currently an announcement when a movement is completed (ie.
endDrag()).Other announcement labels follow this format:
Moving [block label] [disambiguation info] *preposition* [target block label] [disambiguation info]Disambiguation info is of course optional, as is the block label for the moving block if the user has already been moving (in
drag()as opposed tostartDrag()). Only the preposition and the target connection's block label are always included. "Before" and "after" are exclusively reserved for stacked blocks while "inside" and "around" are use for input/output connections and statement inputs.Examples:
startDrag()drag()moving [print “ def ”] after [print “ abc ”](Candidate found on start of move)
moving [] before [print “ abc ”](Block label omitted for successive moves)
moving [if, do] inside [repeat 10, times, do] []moving [] [] around [repeat 10, times, do]moving [2 stack blocks] inside [if false, do, else if true, do, else if false or false, do, else] [else if false or false, do]Note: Sometimes the block labels feel exceedingly verbose, especially when we need to iterate a portion to disambiguate the connection. As a follow-up, I think it could be worth being able to compute a terser label for a block with multiple connections.
Reason for Changes
This provides an improved version of screen reader announcements for move mode that was based on micro:bit's testing. Key improvements include:
Test Coverage
Added and extended tests in the keyboard movement test suite to verify ARIA announcements.
Coverage includes:
before,after,inside,around)if,else if,else)logic_compareblocks)text_join)Tests use real keyboard movement flows and assert against the ARIA live region output.
Documentation
TSDocs were added/updated as needed.
Additional Information
Tests were designed to be resilient to minor wording or localization changes by asserting substrings rather than full string equality. This should make the tests less brittle as we potentially iterate on block and field labels.