Skip to content

dropdown_button: Add A11y names for the menu trigger - #3410

Merged
huacnlee merged 1 commit into
longbridge:mainfrom
sola-ryu:mv/dropdown-button-menu-label
Oct 8, 2026
Merged

huacnlee merged 1 commit into
longbridge:mainfrom
sola-ryu:mv/dropdown-button-menu-label

Conversation

@sola-ryu

@sola-ryu sola-ryu commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

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.

`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
@huacnlee huacnlee changed the title dropdown_button: Name the menu trigger for screen readers dropdown_button: Add A11y names for the menu trigger Oct 8, 2026
@huacnlee
huacnlee merged commit 1e41f17 into longbridge:main Oct 8, 2026
16 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants