Skip to content

Commit

Permalink
fix(OnyxSwitch): add missing semantic switch role (#755)
Browse files Browse the repository at this point in the history
Relates to #754 

Add optional, but semantically helpful `role="switch"` to the
OnyxSwitch.
The “switch” role can be used directly on a native `<input
type="checkbox" />` as shown in the example on
https://www.w3.org/WAI/ARIA/apg/patterns/switch/examples/switch-checkbox/.
  • Loading branch information
JoCa96 committed Mar 25, 2024
1 parent 7b59efd commit e52bb16
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/sit-onyx/src/components/OnyxSwitch/OnyxSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ watch(
:class="[requiredTypeClass]"
:title="props.hideLabel ? props.label : undefined"
>
<!-- Linter incorrectly finds an error. For a native `input` the `aria-checked` is not necessary. There is an open issue about it: https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility/issues/932 -->
<!-- eslint-disable vuejs-accessibility/role-has-required-aria-props -->
<!-- TODO: disable can be removed when https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility/pull/1071 was released -->
<input
ref="inputElement"
v-model="isChecked"
:class="{ 'onyx-switch__input': true, 'onyx-switch__loading': props.loading }"
type="checkbox"
role="switch"
:class="{ 'onyx-switch__input': true, 'onyx-switch__loading': props.loading }"
:aria-label="props.hideLabel ? props.label : undefined"
:disabled="props.disabled || props.loading"
:required="props.required"
Expand Down

0 comments on commit e52bb16

Please sign in to comment.