Skip to content

Commit

Permalink
Merge pull request #27 from susnux/fix/aria-label
Browse files Browse the repository at this point in the history
feat(Select): Allow to customize `aria-label` for l10n
  • Loading branch information
Pytal committed Nov 2, 2023
2 parents e2881d6 + 595df26 commit 58ec531
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions src/components/Select.vue
Expand Up @@ -12,7 +12,7 @@
role="combobox"
:aria-expanded="dropdownOpen.toString()"
:aria-owns="`vs${uid}__listbox`"
aria-label="Search for option"
:aria-label="ariaLabelCombobox"
@mousedown="toggleDropdown($event)"
>
<div ref="selectedOptions" class="vs__selected-options">
Expand All @@ -37,8 +37,8 @@
:disabled="disabled"
type="button"
class="vs__deselect"
:title="`Deselect ${getOptionLabel(option)}`"
:aria-label="`Deselect ${getOptionLabel(option)}`"
:title="ariaLabelDeselectOption(getOptionLabel(option))"
:aria-label="ariaLabelDeselectOption(getOptionLabel(option))"
@mousedown.stop="deselect(option)"
@keydown.enter="keyboardDeselect(option, index)"
>
Expand All @@ -63,8 +63,8 @@
:disabled="disabled"
type="button"
class="vs__clear"
title="Clear Selected"
aria-label="Clear Selected"
:title="ariaLabelClearSelected"
:aria-label="ariaLabelClearSelected"
@click="clearSelection"
>
<component :is="childComponents.Deselect" />
Expand Down Expand Up @@ -295,6 +295,36 @@ export default {
default: 'label',
},
/**
* Allows to customize the `aria-label` set on the comobobox for searching options.
* @type {String}
* @default 'Search for options'
*/
ariaLabelCombobox: {
type: String,
default: 'Search for options',
},
/**
* Allows to customize the `aria-label` set on the clear-selected button
* @type {String}
* @default 'Clear selected'
*/
ariaLabelClearSelected: {
type: String,
default: 'Clear selected',
},
/**
* Allows to customize the `aria-label` for the deselect-option button
* The default is "Deselect " + optionLabel
* @type {(optionLabel: string) => string}
*/
ariaLabelDeselectOption: {
type: Function,
default: (optionLabel) => `Deselect ${optionLabel}`,
},
/**
* Value of the 'autocomplete' field of the input
* element.
Expand Down

0 comments on commit 58ec531

Please sign in to comment.