[fix] Switch uses aria-label on native control

Close #2559
Fix #2549
This commit is contained in:
tarunrajput
2023-07-17 14:54:17 +05:30
committed by Nicolas Gallagher
parent a8a0c1763b
commit 213b616b3c
2 changed files with 3 additions and 2 deletions

View File

@@ -23,7 +23,7 @@ function findSwitchThumb(container) {
describe('components/Switch', () => {
test('accessibilityLabel is applied to native checkbox', () => {
const { container } = render(<Switch accessibilityLabel="switch" />);
const { container } = render(<Switch aria-label="switch" />);
expect(findCheckbox(container).getAttribute('aria-label')).toBe('switch');
});

View File

@@ -44,6 +44,7 @@ const Switch: React.AbstractComponent<
React.ElementRef<typeof View>
> = React.forwardRef((props, forwardedRef) => {
const {
'aria-label': ariaLabel,
accessibilityLabel,
activeThumbColor,
activeTrackColor,
@@ -166,7 +167,7 @@ const Switch: React.AbstractComponent<
];
const nativeControl = createElement('input', {
accessibilityLabel,
'aria-label': ariaLabel || accessibilityLabel,
checked: value,
disabled: disabled,
onBlur: handleFocusState,