Skip to content

sidebar: Name the submenu caret button for assistive tech - #3470

Merged
huacnlee merged 2 commits into
longbridge:mainfrom
noosxe:sidebar-caret-accessible-name
Oct 13, 2026
Merged

huacnlee merged 2 commits into
longbridge:mainfrom
noosxe:sidebar-caret-accessible-name

Conversation

@noosxe

@noosxe noosxe commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Summary

The SidebarMenuItem submenu caret is a real control — its own on_click toggles the submenu (with stop_propagation), its own tab stop — but it ships with no accessible name. Screen readers announce an unnamed "button" once per expandable item, and deterministic role+label audits (the kind apps run as committed receipts) FAIL on every instance.

Button already supports .accessibility_label(...); this names the caret from the item it acts on, via a small pure helper next to collapsed_tooltip so the wording is unit-testable the same way.

Fixes #3467

Before / after

Button  element: Name("caret")  label: <empty>          // before
Button  element: Name("caret")  label: "Toggle Projects submenu"  // after

Repro of the before-state: any Settings-style nav that builds SidebarMenuItem::new(page).children(...) (pages with >1 titled groups); dump the accessibility tree — one unlabeled Button per expandable page.

Test plan

  • New unit test submenu_caret_is_named_after_the_item (mirrors the existing collapsed_tooltip tests)
  • cargo test -p gpui-component --lib sidebar:: — 19 passed
  • cargo clippy -p gpui-component --all-targets -- -D warnings — clean
  • cargo fmt -p gpui-component --check — clean

The submenu caret is a real control — it has its own on_click that
toggles the submenu and its own tab stop — but it shipped with no
accessibility name, so screen readers announced an unnamed 'button'
once per expandable item, and deterministic role+label audits fail on
every instance.

Name it from the item it acts on via a small pure helper (mirroring
collapsed_tooltip), and unit-test the wording.

Fixes longbridge#3467
@noosxe
noosxe force-pushed the sidebar-caret-accessible-name branch from 3a4ed1c to 1e3827e Compare October 12, 2026 22:39

Copy link
Copy Markdown
Member

This overlaps with #3424, which already names the same caret and adds a rendered-control test covering both Expand and Collapse. That draft also respects an explicit SidebarMenuItem::accessibility_label and localizes the wording. Please coordinate with @counterbeing so we keep one implementation for the caret fix.

@huacnlee
huacnlee merged commit 29eaf42 into longbridge:main Oct 13, 2026
16 checks passed
@noosxe
noosxe deleted the sidebar-caret-accessible-name branch October 13, 2026 13:35
huacnlee pushed a commit that referenced this pull request Oct 16, 2026
## Description

The show/hide toggle that `Input::mask_toggle` adds to a masked input
shows only an icon and has no accessible name, so screen readers
announce it as just "button" and accessibility-driven UI tests can't
find it by name. Applications can't name it either, because Input
creates it internally.

This PR names it for the action it takes: "Show password" while the
value is masked and "Hide password" while it is revealed, matching how
the Input docs describe the toggle. The new strings (`Input.Show
Password`, `Input.Hide Password`) are localized for en, zh-CN, zh-HK and
zh-TW.

For example, a settings window with a masked API-token field previously
exposed one unnamed button next to it; it now reads "Show password".

No override builder is added: an override would need a pair of
state-dependent names, so I left it out to keep the change small. Happy
to add one (for example for a field that holds a token rather than a
password) if you'd like it.

This replaces #3424, which was closed as stale while it was a draft;
it's rebased onto current `main`.

(#3424 originally also named the `SidebarMenuItem` submenu caret; #3470
has since done that, so it's now limited to the mask toggle.)

AI-assisted: the change, tests and description were drafted with Claude.

## Screenshot

No visual change. This only adds an accessible name.

## How to Test

- `cargo test -p gpui-kit --features gpui-kit/test-support --locked
--test integration`: passed locally before the rebase; after rebasing
onto current `main`, `input::` passes (187 tests). The new test
`input::mask_toggle_is_named_for_the_action_it_takes` checks the toggle
reads "Show password", then "Hide password" after a click; it fails on
`main` without the source change.
- `cargo clippy --workspace --exclude gpui-shell --exclude gpui-webview
--exclude webview --locked -- --deny warnings`: passed locally.
- `cargo check -p gpui-component --no-default-features --locked`: passed
locally.
- `cargo fmt --all --check`: passed locally.
- Story: in the Input story, the masked input's eye button (States
section, and Password under Content type) shows "Show password" / "Hide
password" in Accessibility Inspector.

## Checklist

- [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and
followed the guidelines.
- [ ] Reviewed the changes in this PR and confirmed AI generated code
(If any) is accurate.
- [ ] Passed `cargo run` for story tests related to the changes.
- [ ] Tested macOS, Windows and Linux platforms performance (if the
change is platform-specific)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar submenu caret button has no accessible name (unlabeled interactive control)

2 participants