Skip to content

Commit 801f95d

Browse files
committed
fix: Reapply "fix: Add role "switch" to toggle component (#5234)"
This reverts commit aa08091.
1 parent aa08091 commit 801f95d

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

‎src/toggle/__tests__/toggle.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ test('renders an input element', () => {
2929
const { wrapper } = renderToggle(<Toggle checked={false} />);
3030
const nativeInput = wrapper.findNativeInput().getElement();
3131
expect(nativeInput.type).toEqual('checkbox');
32+
expect(nativeInput.getAttribute('role')).toEqual('switch');
3233
});
3334

3435
test('synchronizes native and styled controls', () => {

‎src/toggle/internal.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ const InternalToggle = React.forwardRef<ToggleProps.Ref, InternalToggleProps>(
112112
nativeAttributes={nativeInputAttributes}
113113
ref={checkboxRef}
114114
type="checkbox"
115+
role="switch"
115116
checked={checked}
116117
name={name}
117118
aria-disabled={readOnly && !disabled ? 'true' : undefined}

0 commit comments

Comments
 (0)