Skip to content

Commit

Permalink
Add aria-multiselectable
Browse files Browse the repository at this point in the history
  • Loading branch information
Pytal committed Dec 14, 2022
1 parent 709905d commit e082b2c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/components/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
v-append-to-body
class="vs__dropdown-menu"
role="listbox"
:aria-multiselectable="multiple"
tabindex="-1"
@mousedown.prevent="onMousedown"
@mouseup="onMouseUp"
Expand All @@ -109,7 +110,7 @@
'vs__dropdown-option--highlight': index === typeAheadPointer,
'vs__dropdown-option--disabled': !selectable(option),
}"
:aria-selected="index === typeAheadPointer ? true : null"
:aria-selected="optionAriaSelected(option, index)"
@mouseover="selectable(option) ? (typeAheadPointer = index) : null"
@click.prevent.stop="selectable(option) ? select(option) : null"
>
Expand Down Expand Up @@ -1212,6 +1213,24 @@ export default {
)
},
/**
* Determine the `aria-selected` value
* of an option
*
* @param {Object|String} option
* @param {Number} index
* @return {null|boolean}
*/
optionAriaSelected(option, index) {
if (!this.selectable(option)) {
return null
}
if (this.multiple) {
return this.isOptionSelected(option)
}
return index === this.typeAheadPointer ? true : null
},
/**
* Ensures that options are always
* passed as objects to scoped slots.
Expand Down

0 comments on commit e082b2c

Please sign in to comment.