fix(a11y): remove tabindex from disabled elements (#9879)

This commit is contained in:
neverland 2021-11-16 17:52:32 +08:00 committed by GitHub
parent b39784ab3d
commit cdec4bc334
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 5 additions and 19 deletions

View File

@ -131,7 +131,7 @@ export default defineComponent({
}, },
direction.value, direction.value,
])} ])}
tabindex={disabled.value ? -1 : 0} tabindex={disabled.value ? undefined : 0}
aria-checked={props.checked} aria-checked={props.checked}
onClick={onClick} onClick={onClick}
> >

View File

@ -19,7 +19,6 @@ exports[`should render demo and match snapshot 1`] = `
<div> <div>
<div role="checkbox" <div role="checkbox"
class="van-checkbox van-checkbox--disabled" class="van-checkbox van-checkbox--disabled"
tabindex="-1"
aria-checked="false" aria-checked="false"
> >
<div class="van-checkbox__icon van-checkbox__icon--round van-checkbox__icon--disabled"> <div class="van-checkbox__icon van-checkbox__icon--round van-checkbox__icon--disabled">
@ -32,7 +31,6 @@ exports[`should render demo and match snapshot 1`] = `
</div> </div>
<div role="checkbox" <div role="checkbox"
class="van-checkbox van-checkbox--disabled" class="van-checkbox van-checkbox--disabled"
tabindex="-1"
aria-checked="true" aria-checked="true"
> >
<div class="van-checkbox__icon van-checkbox__icon--round van-checkbox__icon--disabled van-checkbox__icon--checked"> <div class="van-checkbox__icon van-checkbox__icon--round van-checkbox__icon--disabled van-checkbox__icon--checked">

View File

@ -116,7 +116,7 @@ export default defineComponent({
return ( return (
<div <div
role="button" role="button"
tabindex={disabled ? -1 : 0} tabindex={disabled ? undefined : 0}
class={[bem('item', { disabled }), { [HAPTICS_FEEDBACK]: !disabled }]} class={[bem('item', { disabled }), { [HAPTICS_FEEDBACK]: !disabled }]}
onClick={() => { onClick={() => {
if (!disabled) { if (!disabled) {

View File

@ -173,7 +173,6 @@ exports[`should render demo and match snapshot 1`] = `
<div class="van-dropdown-menu"> <div class="van-dropdown-menu">
<div class="van-dropdown-menu__bar"> <div class="van-dropdown-menu__bar">
<div role="button" <div role="button"
tabindex="-1"
class="van-dropdown-menu__item van-dropdown-menu__item--disabled" class="van-dropdown-menu__item van-dropdown-menu__item--disabled"
> >
<span class="van-dropdown-menu__title"> <span class="van-dropdown-menu__title">
@ -183,7 +182,6 @@ exports[`should render demo and match snapshot 1`] = `
</span> </span>
</div> </div>
<div role="button" <div role="button"
tabindex="-1"
class="van-dropdown-menu__item van-dropdown-menu__item--disabled" class="van-dropdown-menu__item van-dropdown-menu__item--disabled"
> >
<span class="van-dropdown-menu__title"> <span class="van-dropdown-menu__title">

View File

@ -380,7 +380,6 @@ exports[`disable dropdown item 1`] = `
<div class="van-dropdown-menu"> <div class="van-dropdown-menu">
<div class="van-dropdown-menu__bar"> <div class="van-dropdown-menu__bar">
<div role="button" <div role="button"
tabindex="-1"
class="van-dropdown-menu__item van-dropdown-menu__item--disabled" class="van-dropdown-menu__item van-dropdown-menu__item--disabled"
> >
<span class="van-dropdown-menu__title"> <span class="van-dropdown-menu__title">

View File

@ -71,7 +71,6 @@ exports[`should render demo and match snapshot 1`] = `
> >
<div role="radio" <div role="radio"
class="van-radio van-radio--disabled" class="van-radio van-radio--disabled"
tabindex="-1"
aria-checked="false" aria-checked="false"
> >
<div class="van-radio__icon van-radio__icon--round van-radio__icon--disabled"> <div class="van-radio__icon van-radio__icon--round van-radio__icon--disabled">
@ -84,7 +83,6 @@ exports[`should render demo and match snapshot 1`] = `
</div> </div>
<div role="radio" <div role="radio"
class="van-radio van-radio--disabled" class="van-radio van-radio--disabled"
tabindex="-1"
aria-checked="true" aria-checked="true"
> >
<div class="van-radio__icon van-radio__icon--round van-radio__icon--disabled van-radio__icon--checked"> <div class="van-radio__icon van-radio__icon--round van-radio__icon--disabled van-radio__icon--checked">

View File

@ -195,7 +195,7 @@ export default defineComponent({
role="radio" role="radio"
style={style} style={style}
class={bem('item')} class={bem('item')}
tabindex={0} tabindex={disabled ? undefined : 0}
aria-setsize={+count} aria-setsize={+count}
aria-posinset={score} aria-posinset={score}
aria-checked={!isVoid} aria-checked={!isVoid}
@ -231,7 +231,7 @@ export default defineComponent({
readonly: props.readonly, readonly: props.readonly,
disabled: props.disabled, disabled: props.disabled,
})} })}
tabindex={0} tabindex={props.disabled ? undefined : 0}
onTouchstart={onTouchStart} onTouchstart={onTouchStart}
onTouchmove={onTouchMove} onTouchmove={onTouchMove}
> >

View File

@ -313,11 +313,9 @@ exports[`should render demo and match snapshot 1`] = `
<div> <div>
<div role="radiogroup" <div role="radiogroup"
class="van-rate van-rate--disabled" class="van-rate van-rate--disabled"
tabindex="0"
> >
<div role="radio" <div role="radio"
class="van-rate__item" class="van-rate__item"
tabindex="0"
aria-setsize="5" aria-setsize="5"
aria-posinset="1" aria-posinset="1"
aria-checked="true" aria-checked="true"
@ -327,7 +325,6 @@ exports[`should render demo and match snapshot 1`] = `
</div> </div>
<div role="radio" <div role="radio"
class="van-rate__item" class="van-rate__item"
tabindex="0"
aria-setsize="5" aria-setsize="5"
aria-posinset="2" aria-posinset="2"
aria-checked="true" aria-checked="true"
@ -337,7 +334,6 @@ exports[`should render demo and match snapshot 1`] = `
</div> </div>
<div role="radio" <div role="radio"
class="van-rate__item" class="van-rate__item"
tabindex="0"
aria-setsize="5" aria-setsize="5"
aria-posinset="3" aria-posinset="3"
aria-checked="true" aria-checked="true"
@ -347,7 +343,6 @@ exports[`should render demo and match snapshot 1`] = `
</div> </div>
<div role="radio" <div role="radio"
class="van-rate__item" class="van-rate__item"
tabindex="0"
aria-setsize="5" aria-setsize="5"
aria-posinset="4" aria-posinset="4"
aria-checked="false" aria-checked="false"
@ -357,7 +352,6 @@ exports[`should render demo and match snapshot 1`] = `
</div> </div>
<div role="radio" <div role="radio"
class="van-rate__item" class="van-rate__item"
tabindex="0"
aria-setsize="5" aria-setsize="5"
aria-posinset="5" aria-posinset="5"
aria-checked="false" aria-checked="false"

View File

@ -294,7 +294,7 @@ export default defineComponent({
<div <div
role="slider" role="slider"
class={getButtonClassName(index)} class={getButtonClassName(index)}
tabindex={props.disabled || props.readonly ? -1 : 0} tabindex={props.disabled || props.readonly ? undefined : 0}
aria-valuemin={+props.min} aria-valuemin={+props.min}
aria-valuenow={current} aria-valuenow={current}
aria-valuemax={+props.max} aria-valuemax={+props.max}

View File

@ -76,7 +76,6 @@ exports[`should render demo and match snapshot 1`] = `
> >
<div role="slider" <div role="slider"
class="van-slider__button-wrapper van-slider__button-wrapper--right" class="van-slider__button-wrapper van-slider__button-wrapper--right"
tabindex="-1"
aria-valuemin="0" aria-valuemin="0"
aria-valuenow="50" aria-valuenow="50"
aria-valuemax="100" aria-valuemax="100"