Skip to content

input: Name the mask toggle - #3424

Closed
counterbeing wants to merge 1 commit into
longbridge:mainfrom
counterbeing:a11y-sidebar-caret-input-mask
Closed

counterbeing wants to merge 1 commit into
longbridge:mainfrom
counterbeing:a11y-sidebar-caret-input-mask

Conversation

@counterbeing

@counterbeing counterbeing commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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 PR 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 and reviewed by me.

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 (392 passed). 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

  • I have read the CONTRIBUTING 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)

The eye button added by `mask_toggle()` shows only an icon, so screen
readers announced it as just "button" and accessibility-driven UI tests
could not find it by name. Applications can't name it either, because
Input creates it internally.

It is now named for the action it takes, "Show password" while the value
is masked and "Hide password" while it is shown, localized for en, zh-CN,
zh-HK and zh-TW.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@counterbeing
counterbeing force-pushed the a11y-sidebar-caret-input-mask branch from 2085965 to 491b8be Compare October 13, 2026 22:00
@counterbeing counterbeing changed the title sidebar, input: Name the submenu caret and the mask toggle input: Name the mask toggle Oct 13, 2026
@huacnlee

Copy link
Copy Markdown
Member

Close old no response PRs, if you want continue, you can just reopen.

@huacnlee huacnlee closed this Oct 14, 2026
huacnlee pushed a commit that referenced this pull request Oct 16, 2026
## Description

The clear button that `Input`, `Select`, `Combobox` and `DatePicker`
show with `cleanable(true)` is icon-only and has no accessible name.
Screen readers announce it as just "button" (TalkBack: "Unlabelled,
button"), and accessibility-driven UI tests can't find it by name.
Applications can't name it either, because the component creates it.

It is now named "Clear", localized for en, zh-CN, zh-HK and zh-TW like
the other `Input` strings.

The mask toggle of a masked input has the same gap. #3424 named it
(closed for inactivity, and its author can reopen it), so this PR leaves
the toggle out.

I found this while testing Kit on Android through gpui-mobile, where
every clear button is an unnamed `android.widget.Button`.

## Screenshot

No visual change; this only adds an accessible name. Android (OnePlus
CPH2581, Android 16), an `Input` with `cleanable(true)`:

| Before | After |
| --- | --- |
| `uiautomator dump`: `class="android.widget.Button" text=""
content-desc=""` ([full
dump](https://raw.githubusercontent.com/Bombatomica64/Gpui-android/main/docs/demos/a11y-text-input-baseline.xml))
| `content-desc="Clear"`; TalkBack reads "Clear" and activates it |

## How to Test

- New UI test `input::clear_button_is_named`: renders a cleanable
`Input` and checks the button's label is "Clear".
- `cargo test -p gpui-kit --features test-support --test integration --
input:: input_focus::`: 191 passed (187 `input::`, incl. the new test,
and 4 `input_focus::`)
- `cargo test -p gpui-base --features test-support --lib input`: 359
passed
- `cargo clippy -p gpui-base -p gpui-component -p gpui-kit --features
gpui-kit/test-support --tests -- --deny warnings`, `cargo fmt --all --
--check`, `typos`: clean.
- On Android, in my test app (Kit 0.7.1 plus this change, through
gpui-mobile): uiautomator shows `content-desc="Clear"`, and TalkBack
focuses and activates the button.

## Checklist

- [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and
followed the guidelines.
- [x] 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. (Not
run: no desktop session here; the UI test covers the label.)
- [ ] Tested macOS, Windows and Linux platforms performance (if the
change is platform-specific) (Not platform-specific; a label only.)

Thanks for taking the time to review this.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@counterbeing counterbeing mentioned this pull request Oct 16, 2026
1 of 4 tasks
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants