Skip to content

Commit 9852c89

Browse files
nmergetgithub-actions[bot]mfranzke
authored
chore: removed aria-checked from switch which is type=checkbox (#4496)
* chore: removed aria-checked from switch which is type=checkbox * auto update snapshots (#4498) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Maximilian Franzke <[email protected]>
1 parent f6baa38 commit 9852c89

File tree

4 files changed

+2
-21
lines changed

4 files changed

+2
-21
lines changed
52 Bytes
Loading

packages/components/src/components/switch/model.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ export type DBSwitchProps = DBSwitchDefaultProps &
3232
IconProps &
3333
IconAfterProps;
3434

35-
export type DBSwitchDefaultState = {
36-
_checked?: boolean;
37-
};
35+
export type DBSwitchDefaultState = {};
3836

3937
export type DBSwitchState = DBSwitchDefaultState &
4038
GlobalState &

packages/components/src/components/switch/switch.lite.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
onMount,
3-
onUpdate,
43
Show,
54
useDefaultProps,
65
useMetadata,
@@ -36,18 +35,11 @@ export default function DBSwitch(props: DBSwitchProps) {
3635
// jscpd:ignore-start
3736
const state = useStore<DBSwitchState>({
3837
_id: undefined,
39-
_checked: useTarget({
40-
react: (props as any)['defaultChecked'] ?? false,
41-
default: false
42-
}),
4338
handleChange: (event: ChangeEvent<HTMLInputElement>) => {
4439
if (props.onChange) {
4540
props.onChange(event);
4641
}
4742

48-
// We have different ts types in different frameworks, so we need to use any here
49-
state._checked = (event.target as any)?.['checked'];
50-
5143
useTarget({
5244
angular: () =>
5345
handleFrameworkEventAngular(state, event, 'checked'),
@@ -70,12 +62,6 @@ export default function DBSwitch(props: DBSwitchProps) {
7062
state._id = props.id ?? `switch-${uuid()}`;
7163
});
7264

73-
onUpdate(() => {
74-
if (props.checked !== undefined && props.checked !== null) {
75-
state._checked = getBoolean(props.checked);
76-
}
77-
}, [props.checked]);
78-
7965
// jscpd:ignore-end
8066

8167
return (
@@ -90,7 +76,6 @@ export default function DBSwitch(props: DBSwitchProps) {
9076
id={state._id}
9177
type="checkbox"
9278
role="switch"
93-
aria-checked={getBooleanAsString(state._checked)}
9479
ref={_ref}
9580
checked={getBoolean(props.checked, 'checked')}
9681
value={props.value}

showcases/e2e/switch/switch-a11y.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ test.describe('DBSwitch', () => {
77
runAxeCoreTest({ path: '03/switch', color: lvl3 });
88
runAxeCoreTest({ path: '03/switch', density: 'functional' });
99
runA11yCheckerTest({
10-
path: '03/switch',
11-
// It's an issue in the tool: https://github.com/IBMa/equal-access/issues/842
12-
aCheckerDisableRules: ['aria_attribute_valid']
10+
path: '03/switch'
1311
});
1412
});

0 commit comments

Comments
 (0)