Repository navigation
dropdown_button: Add A11y names for the menu trigger - #3410
Merged
Merged
Conversation
`DropdownButton` builds the caret half itself as an icon-only `Button`, so a screen reader announced it as just "button", and an application had no way to name it: the inner `Button` it is given names only the action half. The trigger now has the localized "More options" name by default, and `DropdownButton::menu_accessibility_label` gives it a more specific one, such as "More save options". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DHBYT8JhqczL6GhYZoKgww
linruohan
pushed a commit
to linruohan/gpui-component
that referenced
this pull request
Oct 9, 2026
A `DropdownButton`'s menu trigger shows only a caret, so it has no
visible label for a screen reader to announce. The action half is named
by the inner `Button`, but the trigger's accessible name fell back to
nothing.
This change adds `DropdownButton::menu_accessibility_label`, which sets
the name announced for the menu trigger. Without it, the trigger gets a
localized default ("More options") via a new
`DropdownButton.more_options` locale key, so the caret-only trigger
always has a name. The default is translated for en, zh-CN, zh-HK and
zh-TW, and the storybook docs mention the new builder.
Test `dropdown_button_names_its_menu_trigger` asserts both the explicit
label and the localized default.
## Public API
### gpui-component
- `DropdownButton::menu_accessibility_label(impl Into<SharedString>) ->
Self` — Sets the screen-reader name for the menu trigger; defaults to
the localized "More options".
---
This PR is 100% AI-generated: originally drafted with Claude on
2026-10-04, rebased onto current main (the test was ported to the
renamed `#[gpui_kit::test]` macro), reviewed and validated by the
contributor: `cargo fmt --check`, `cargo clippy -p gpui-component
--all-targets -- --deny warnings`, and the components test suite (7
passed, including dropdown_button_names_its_menu_trigger) are all green.
Co-authored-by: Sola <sola-ryu@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
A
DropdownButton's menu trigger shows only a caret, so it has no visible label for a screen reader to announce. The action half is named by the innerButton, but the trigger's accessible name fell back to nothing.This change adds
DropdownButton::menu_accessibility_label, which sets the name announced for the menu trigger. Without it, the trigger gets a localized default ("More options") via a newDropdownButton.more_optionslocale key, so the caret-only trigger always has a name. The default is translated for en, zh-CN, zh-HK and zh-TW, and the storybook docs mention the new builder.Test
dropdown_button_names_its_menu_triggerasserts both the explicit label and the localized default.Public API
gpui-component
DropdownButton::menu_accessibility_label(impl Into<SharedString>) -> Self— Sets the screen-reader name for the menu trigger; defaults to the localized "More options".This PR is 100% AI-generated: originally drafted with Claude on 2026-10-04, rebased onto current main (the test was ported to the renamed
#[gpui_kit::test]macro), reviewed and validated by the contributor:cargo fmt --check,cargo clippy -p gpui-component --all-targets -- --deny warnings, and the components test suite (7 passed, including dropdown_button_names_its_menu_trigger) are all green.