Skip to content

Conversation

Pseudo-Sid26
Copy link

Title Dev: warn when slider controls are missing an accessible name (help with #33669)

Body Summary

Add a DEV-only console warning when a slider control (implicit via or any element with role="slider") is rendered without an obvious accessible name source (aria-label, aria-labelledby, or title).
Motivation

Screen readers on Windows (Narrator / NVDA / JAWS) can announce unlabeled sliders ambiguously (e.g. “slider 3”), which is confusing for users. This diagnostic helps authors catch missing accessible names during development.
What changed

ReactDOMComponent.js
In validatePropertiesInDevelopment, warn when:
type === 'input' && props.type === 'range' and no aria-label / aria-labelledby / title present.
props.role === 'slider' and no aria-label / aria-labelledby / title present.
Warning is conservative and props-based only to avoid false positives.
packages/react-dom/src/tests/ReactDOMInvalidARIAHook-test.js
Added a unit test asserting the new dev warning is emitted for an unlabeled .
Testing / Validation

Install deps:
npm install OR yarn
Run the added test:
npx jest packages/react-dom/src/tests/ReactDOMInvalidARIAHook-test.js -i --colors
Manual smoke-check:
Run an app in development, render without aria-* or title, and verify a single console.error appears instructing to add aria-label / aria-labelledby / title.
Notes / Limitations

This is a developer-only diagnostic gated by DEV; it does not affect production bundles.
The check uses props-only detection (aria-label / aria-labelledby / title). It does not attempt to walk the DOM to detect associated to avoid false positives at this location. Consider a follow-up DOM-level dev checker if maintainers want label association detection.
Wording can be adjusted if maintainers prefer different guidance or links to docs.
Issue

Helps resolve / relates to: #33669

Copy link

meta-cla bot commented Aug 16, 2025

Hi @Pseudo-Sid26!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Copy link

meta-cla bot commented Aug 16, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed label Aug 16, 2025
@react-sizebot
Copy link

Comparing: 546bac7...fd6d959

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 530.18 kB 530.18 kB = 93.39 kB 93.39 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 655.81 kB 655.81 kB = 115.31 kB 115.30 kB
facebook-www/ReactDOM-prod.classic.js = 675.58 kB 675.58 kB = 118.54 kB 118.54 kB
facebook-www/ReactDOM-prod.modern.js = 666.00 kB 666.00 kB = 116.87 kB 116.87 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js +0.52% 66.91 kB 67.25 kB +0.69% 16.82 kB 16.94 kB

Generated by 🚫 dangerJS against fd6d959

@Pseudo-Sid26 Pseudo-Sid26 force-pushed the fix/slider-accessible-name branch from 731e1d8 to d52330a Compare August 28, 2025 13:42
@Pseudo-Sid26 Pseudo-Sid26 force-pushed the fix/slider-accessible-name branch from 944b037 to 1e78791 Compare August 28, 2025 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants