Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Select): Allow to customize aria-label for l10n #27

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 35 additions & 5 deletions src/components/Select.vue
Original file line number Diff line number Diff line change
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