Skip to content

dialog: make the close button accessible - #2969

Merged
huacnlee merged 8 commits into
longbridge:mainfrom
grishy:sg-dialog-close-label
Sep 6, 2026
Merged

dialog: make the close button accessible#2969
huacnlee merged 8 commits into
longbridge:mainfrom
grishy:sg-dialog-close-label

Conversation

@grishy

@grishy grishy commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

The dialog’s close button has no accessible name or AXPress action on macOS. This patch gives the button a localized name and moves the existing Cancel handler from its wrapper onto the button.

Native accessibility dumps of the same close button, before and after (unrelated fields omitted):

 {
   "role": "AXButton",
-  "title": "",
+  "title": "Close",
   "enabled": "1",
-  "actions": []
+  "actions": ["AXPress"]
 }

Appearance and public API are unchanged. The name uses Dialog.close (need to check non-English versions). Closing still goes through Cancel, including the on_cancel callback and its ability to prevent dismissal.

Screenshot

Dialog with its top-right Close button

How to Test

MTL_HUD_ENABLED=1 ./script/run-story-macos Dialog
  1. Open Custom Width (400px).
  2. Use Xcode’s Accessibility Inspector to inspect the top-right close button: AXButton, name Close, action AXPress.
  3. Perform AXPress: the dialog should close.
  4. Reopen, focus Close, and press Space: it should close again.

Use Space for button activation: the existing Dialog Enter binding invokes Confirm instead, a separate keyboard-routing issue. Didn't fix here.

Code checks
cargo test -p gpui-base -p gpui-component --lib --locked
cargo clippy -p gpui-base -p gpui-component -p gpui-component-story --all-targets --locked -- -D warnings
rustfmt --check --edition 2024 crates/component/src/dialog/dialog.rs

771 base and 418 component tests passed, along with strict Clippy and formatting. No new Rust test was added; the close-button regression was checked through native accessibility.

Checklist

  • Read CONTRIBUTING.md.
  • Human-reviewed the patch, including the AI-assisted changes.
  • Manually tested the patch as a human reviewer.
  • Windows and Linux runtime validation.

AI assistance

OpenAI’s gpt-6-astra helped prepare the patch, native verification scripts, and this description. I reviewed the changes; the checks reported above were run by the agent and myself also initially

Put the localized name and Cancel action on the same semantic Button.
The outer DialogClose wrapper leaves the named child without native AXPress.
@grishy

grishy commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Also in macOS xcode
image

@huacnlee
huacnlee merged commit 21e802b into longbridge:main Sep 6, 2026
9 checks passed
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