Skip to content

Commit 213b616

Browse files
tarunrajputnecolas
authored andcommittedJul 20, 2023
[fix] Switch uses aria-label on native control
Close #2559 Fix #2549
1 parent a8a0c17 commit 213b616

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
 

‎packages/react-native-web/src/exports/Switch/__tests__/index-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function findSwitchThumb(container) {
2323

2424
describe('components/Switch', () => {
2525
test('accessibilityLabel is applied to native checkbox', () => {
26-
const { container } = render(<Switch accessibilityLabel="switch" />);
26+
const { container } = render(<Switch aria-label="switch" />);
2727
expect(findCheckbox(container).getAttribute('aria-label')).toBe('switch');
2828
});
2929

‎packages/react-native-web/src/exports/Switch/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const Switch: React.AbstractComponent<
4444
React.ElementRef<typeof View>
4545
> = React.forwardRef((props, forwardedRef) => {
4646
const {
47+
'aria-label': ariaLabel,
4748
accessibilityLabel,
4849
activeThumbColor,
4950
activeTrackColor,
@@ -166,7 +167,7 @@ const Switch: React.AbstractComponent<
166167
];
167168

168169
const nativeControl = createElement('input', {
169-
accessibilityLabel,
170+
'aria-label': ariaLabel || accessibilityLabel,
170171
checked: value,
171172
disabled: disabled,
172173
onBlur: handleFocusState,

0 commit comments

Comments
 (0)
Please sign in to comment.