Skip to content

Commit

Permalink
fix(Switch): aria-label prop not applying to native control
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunrajput committed Jul 17, 2023
1 parent 15f7899 commit 19be431
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/Switch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const Switch: React.AbstractComponent<
React.ElementRef<typeof View>
> = React.forwardRef((props, forwardedRef) => {
const {
'aria-label': ariaLabel,
accessibilityLabel,
activeThumbColor,
activeTrackColor,
Expand Down Expand Up @@ -166,6 +167,7 @@ const Switch: React.AbstractComponent<
];

const nativeControl = createElement('input', {
'aria-label': ariaLabel,
accessibilityLabel,
checked: value,
disabled: disabled,
Expand Down

0 comments on commit 19be431

Please sign in to comment.