Skip to content

Commit 944b037

Browse files
committed
Revert "Dev: warn when slider controls missing an accessible name (help with #33669)"
This reverts commit d52330a.
1 parent 9e90d17 commit 944b037

File tree

2 files changed

+0
-56
lines changed

2 files changed

+0
-56
lines changed

packages/react-dom-bindings/src/client/ReactDOMComponent.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -111,39 +111,6 @@ function validatePropertiesInDevelopment(type: string, props: any) {
111111
'probably not intentional.',
112112
);
113113
}
114-
115-
// Dev-time accessibility hint: certain controls (for example sliders)
116-
// must have an accessible name for screen readers to announce them
117-
// correctly on some platforms (notably Windows). We can't reliably
118-
// detect associated <label> elements here, so warn when common name
119-
// sources are missing to help authors catch the issue early.
120-
try {
121-
const hasAccessibleNameProp =
122-
props['aria-label'] != null || props['aria-labelledby'] != null ||
123-
props.title != null;
124-
125-
// Check for implicit input type=range -> role=slider
126-
if (type === 'input') {
127-
const inputType = props.type;
128-
if (inputType === 'range' && !hasAccessibleNameProp) {
129-
console.error(
130-
'A control with role `slider` (\"<input type=\"range\">\") ' +
131-
'is missing an accessible name. Add `aria-label`, `aria-labelledby` ' +
132-
'or a `title` so screen readers can announce the control.',
133-
);
134-
}
135-
}
136-
137-
// Check for explicit role=slider on any element
138-
if (props.role === 'slider' && !hasAccessibleNameProp) {
139-
console.error(
140-
'An element with `role="slider"` is missing an accessible name. ' +
141-
'Add `aria-label`, `aria-labelledby` or `title` so screen readers can announce the control.',
142-
);
143-
}
144-
} catch (e) {
145-
// Defensive: in case props accessors throw.
146-
}
147114
}
148115
}
149116

packages/react-dom/src/__tests__/ReactDOMInvalidARIAHook-test.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,27 +107,4 @@ describe('ReactDOMInvalidARIAHook', () => {
107107
]);
108108
});
109109
});
110-
111-
describe('slider accessible name warning', () => {
112-
it('should warn when <input type="range"> is missing an accessible name', async () => {
113-
jest.resetModules();
114-
const React = require('react');
115-
const ReactDOMClient = require('react-dom/client');
116-
const act = require('internal-test-utils').act;
117-
const assertConsoleErrorDev =
118-
require('internal-test-utils').assertConsoleErrorDev;
119-
120-
const container = document.createElement('div');
121-
const root = ReactDOMClient.createRoot(container);
122-
123-
await act(() => {
124-
root.render(<input type="range" />);
125-
});
126-
127-
assertConsoleErrorDev([
128-
'A control with role `slider` ("<input type="range">") is missing an accessible name. Add `aria-label`, `aria-labelledby` or a `title` so screen readers can announce the control.\n' +
129-
' in input (at **)',
130-
]);
131-
});
132-
});
133110
});

0 commit comments

Comments
 (0)