feat: FieldDropdown ARIA#9766
Open
mikeharv wants to merge 2 commits intoRaspberryPiFoundation:v13from
Open
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 #9657
Proposed Changes
This PR add the ARIA implementation of
FieldDropdown.Key changes include:
Adds correct ARIA role and state management to the dropdown trigger element:
role="button"aria-expandeddynamically based on whether the dropdown menu is openaria-haspopup="listbox"to indicate the popup typearia-controlsto reference the unique ID of the dropdown menuIntroduces a Blockly-unique ID for the dropdown menu root element so it can be referenced reliably via
aria-controlsImproves menu item accessibility structure:
Enhances ARIA label computation for dropdown options:
ariaLabel, thenaltas fallbackReason for Changes
This change establishes a baseline pattern in
FieldDropdownso 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
This change is covered by an expanded suite of ARIA-focused unit tests for
FieldDropdown.Simple Dropdown
Dropdown with Option ARIA labels
Dropdown with image options
Dropdown with HTMLElement options
Documentation
New methods include TSDocs.
Additional Information
Further follow-up work will be required to update built-in Blockly block definitions to fully utilize improved ARIA option labeling. This could to updating some tests here as block definitions change.