Skip to content

slider: Add accessibility labels - #3494

Merged
madcodelife merged 2 commits into
longbridge:mainfrom
lurenjia534:fix/slider-accessibility-label-3468
Oct 13, 2026
Merged

madcodelife merged 2 commits into
longbridge:mainfrom
lurenjia534:fix/slider-accessibility-label-3468

Conversation

@lurenjia534

@lurenjia534 lurenjia534 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3468

Description

Base and Component Slider expose a slider role and numeric metadata, but neither provides an API for naming the control. Add an optional accessibility_label(...) builder to both layers. Component forwards the name to Base, which applies it to its existing Role::Slider node.

The label defaults to None, preserving existing callers. The change follows the existing builder naming and Base/Component ownership boundary. Slider state, bounds, step, orientation, pointer handling and accessibility increment/decrement handlers retain their existing implementation. Per-thumb semantics for range sliders are outside this change.

Add one rendered-node regression to the existing Slider integration module and document the API for Base and Component in English and Simplified Chinese. The production diff contains 7 files: 128 insertions and 8 deletions. The screenshot fixture and verification artifacts are published on a separate fork evidence branch.

Screenshot

Actual Linux GPUI WGPU offscreen captures, using the same fixture on clean latest-upstream snapshots before and after applying the patch. The lower verification panel reads labels from real rendered GPUI nodes; it is only part of the review fixture.

Theme Before After
Light before-light after-light
Dark before-dark after-dark

The controls-only captures have 0 changed pixels in both themes.

Controls-only captures and raw observations are available at a fixed evidence commit.

Public API

gpui-base

Added to gpui_base::slider::Slider:

pub fn accessibility_label(mut self, label: impl Into<SharedString>) -> Self

Sets the accessible name on the existing Slider node.

gpui-component

Added to gpui_component::slider::Slider:

pub fn accessibility_label(mut self, label: impl Into<SharedString>) -> Self

Forwards the accessible name to the underlying Base Slider.

How to Test

Run from the repository root (omit --offline if dependencies are not cached):

cargo test --locked --offline -p gpui-kit --features test-support --test integration slider_steps::
cargo test --locked --offline -p gpui-base -p gpui-component --lib slider::tests
cargo check --locked --offline -p gpui-base -p gpui-component --lib
cargo clippy --locked --offline -p gpui-base -p gpui-component --lib -- -D warnings
cargo clippy --locked --offline -p gpui-kit --features test-support --test integration -- -D warnings
rustfmt --edition 2024 --check \
  crates/base/src/slider.rs \
  crates/component/src/slider.rs \
  crates/kit/tests/integration/slider_steps.rs
git diff --check

All commands passed on upstream base 8d4907da456a4f363c7ee1c22c553f44c3c58500 plus commit 0825fb2f5ec5f9c1a2c93ef01cc57961d5c4443a. There were 4 passing Slider integration tests, 4 passing Base unit tests, and 2 passing Component unit tests.

The added regression queries Base and Component by their existing stable Slider IDs and checks role, node count and label across omitted labels, two distinct labels, non-ASCII renaming, and label removal on a later render. The three existing pointer/disabled integration regressions are unchanged.

Independent before/after verification with the review fixture:

  • Before: the new builders fail to compile with exactly two E0599 errors; the existing APIs render four Slider nodes whose labels are all None.
  • After: the new builders compile, and all six theme/case combinations pass for distinct English names, Chinese renaming and removal.
  • Element identity paths, roles, state values and bounds remain equal across builds. Controls-only screenshots are pixel-identical in both themes.

Rendered-node observations and image hashes and validation command logs are available for review. A reproduction script recreates both clean source revisions, checks expected compilation/runtime results and compares the controls-only PNGs:

git clone --branch evidence/slider-3468-0825fb2f https://github.com/lurenjia534/gpui-component.git slider-3468-review
cd slider-3468-review
python3 evidence/slider-3468/reproduce.py --output review-output

Native screen-reader speech, the native Story window and macOS/Windows runtime verification have not been performed. The offscreen fixture verifies GPUI rendering and node metadata.

AI Assistance

AI assisted with issue analysis, the optional label implementation, the rendered-node regression, bilingual documentation, static review, validation commands and the separate screenshot fixture.

Checklist

  • Repository contributing, design and coding guidance was consulted; the change is focused on Slider exposes no way to name the control (no accessibility label API) #3468.
  • Contributor reviewed the generated implementation and test evidence.
  • Rust compilation, regression tests, formatting and Clippy passed.
  • A relevant native Story/example was run and its OS accessibility metadata was checked.
  • Native cross-platform verification was performed.

lurenjia534 and others added 2 commits October 13, 2026 20:56
Add optional accessible names to Base and Component Slider builders and
apply them to the existing Slider node. Forward names through Component,
cover rendered-node updates, and document both APIs in English and Chinese.

Fixes longbridge#3468

AI-assisted implementation, regression test, and documentation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@madcodelife

Copy link
Copy Markdown
Member

Thank you.

@madcodelife
madcodelife enabled auto-merge (squash) October 13, 2026 15:10
@madcodelife
madcodelife disabled auto-merge October 13, 2026 15:10
@madcodelife
madcodelife enabled auto-merge (squash) October 13, 2026 15:10
@madcodelife
madcodelife merged commit c5f8eca into longbridge:main Oct 13, 2026
16 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.

Slider exposes no way to name the control (no accessibility label API)

2 participants