feat: ARIA for other field classes#9772
Merged
mikeharv merged 2 commits intoRaspberryPiFoundation:v13from Apr 29, 2026
Merged
Conversation
gonfunko
approved these changes
Apr 29, 2026
| /** @type {string} */ | ||
| /// dropdown choice - When the user clicks on a variable block, this is one of the dropdown menu choices. It is used to rename the current variable. See [https://github.com/RaspberryPiFoundation/blockly/wiki/Variables#dropdown-menu https://github.com/RaspberryPiFoundation/blockly/wiki/Variables#dropdown-menu]. | ||
| Blockly.Msg.RENAME_VARIABLE = 'Rename variable...'; | ||
| Blockly.Msg.RENAME_VARIABLE = 'Rename the "%1" variable'; |
Contributor
There was a problem hiding this comment.
I think it would be safer to add this as a new string since it adds a placeholder where there was none - I'm not sure if interpolating throws or otherwise has issues if a placeholder is/isn't present as expected, but might be best to err on the side of caution?
Contributor
Author
There was a problem hiding this comment.
Interpolation is done via .replace() which doesn't throw if there's a problem. We discussed this and agreed to leave it as a replacement for an existing string.
Comment on lines
+136
to
+139
| const element = this.getFocusableElement(); | ||
| if (!element) return; | ||
|
|
||
| aria.setState(element, aria.State.HIDDEN, true); |
Contributor
There was a problem hiding this comment.
Can this just go in createTextElement_?
Contributor
Author
There was a problem hiding this comment.
Moved to initView() as this class wasn't already extending createTextElement_.
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 #9659 and #9658
Proposed Changes
This PR add the ARIA implementation of
FieldCheckbox,FieldImage,FieldLabel, andFieldVariable. It also makes some minor adjustments toFieldNumberand other more general changes to how ARIA methods are used.General updates
computeAriaLabelwas updated toincludeTypeInfo = trueby default. Currently, we only exclude type info for move mode announcements, which makes it the clear exception rather than the rule.recomputeAriaContext()fromprivatetoprotected. We expect develops may need to extend this method in their custom field subclasses.FieldVariable'Variable "i"''Rename the "i" variable'FieldCheckboxaria-checkedstate based on whether it's been checked.aria-hiddenif in the flyout.aria-checkedstate.)FieldImageFieldLabelaria-hiddensince it should not be navigable.FieldNumberaria-valueminandaria-valuemaxlogic as it likely never worked. (These properties are for range widgets like sliders.)Reason for Changes
This change continues the baseline pattern (#9683, #9744, #9766 ) so that fields have meaningful default accessibility behavior without requiring every implementation to solve the same problems independently. It ensures that ARIA labeling stays in sync with field state and that fields communicate their interactivity in a predictable way.
At the same time, this approach intentionally leaves room for customization, allowing specific field types to provide more tailored or context-aware accessibility behavior where needed.
Test Coverage
Added/updated unit tests for ARIA behavior on checkbox, dropdown, image, label, number, textinput, and variable fields.
Tests cover:
Notes:
equaltoincludebecause the label now also includes the ARIA type name.FieldVariablebenefits from the ARIA logic inFieldDropdown, so those tests were written to reinforce that alignment.Documentation
Additional Information