react icon indicating copy to clipboard operation
react copied to clipboard

Dev: warn when slider controls missing an accessible name (help with …

Open Pseudo-Sid26 opened this issue 4 months ago • 4 comments

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

Helps resolve / relates to: #33669

Pseudo-Sid26 avatar Aug 16 '25 14:08 Pseudo-Sid26

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!

meta-cla[bot] avatar Aug 16 '25 14:08 meta-cla[bot]

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[bot] avatar Aug 16 '25 15:08 meta-cla[bot]

Comparing: 546bac728125bed821c0205e3d7216a7c9a563cb...fd6d959a90b3fce3a259e110b2e54f80e571bbc9

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 :no_entry_sign: dangerJS against fd6d959a90b3fce3a259e110b2e54f80e571bbc9

react-sizebot avatar Aug 19 '25 20:08 react-sizebot

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

github-actions[bot] avatar Dec 01 '25 17:12 github-actions[bot]