AutoComplete: dropdown button accessibility improvements

pull/5507/head
tugcekucukoglu 2024-03-27 16:26:52 +03:00
parent 50142ad225
commit a878772bae
1 changed files with 17 additions and 2 deletions

View File

@ -20,7 +20,7 @@
aria-haspopup="listbox" aria-haspopup="listbox"
aria-autocomplete="list" aria-autocomplete="list"
:aria-expanded="overlayVisible" :aria-expanded="overlayVisible"
:aria-controls="id + '_list'" :aria-controls="panelId"
:aria-activedescendant="focused ? focusedOptionId : undefined" :aria-activedescendant="focused ? focusedOptionId : undefined"
@focus="onFocus" @focus="onFocus"
@blur="onBlur" @blur="onBlur"
@ -98,7 +98,18 @@
<SpinnerIcon v-else :class="[cx('loadingIcon'), loadingIcon]" spin aria-hidden="true" v-bind="ptm('loadingIcon')" /> <SpinnerIcon v-else :class="[cx('loadingIcon'), loadingIcon]" spin aria-hidden="true" v-bind="ptm('loadingIcon')" />
</slot> </slot>
<slot name="dropdownbutton" :toggleCallback="(event) => onDropdownClick(event)"> <slot name="dropdownbutton" :toggleCallback="(event) => onDropdownClick(event)">
<button v-if="dropdown" ref="dropdownButton" type="button" tabindex="-1" :class="[cx('dropdownButton'), dropdownClass]" :disabled="disabled" aria-hidden="true" @click="onDropdownClick" v-bind="ptm('dropdownButton')"> <button
v-if="dropdown"
ref="dropdownButton"
type="button"
:class="[cx('dropdownButton'), dropdownClass]"
:disabled="disabled"
aria-haspopup="listbox"
:aria-expanded="overlayVisible"
:aria-controls="panelId"
@click="onDropdownClick"
v-bind="ptm('dropdownButton')"
>
<slot name="dropdownicon" :class="dropdownIcon"> <slot name="dropdownicon" :class="dropdownIcon">
<component :is="dropdownIcon ? 'span' : 'ChevronDownIcon'" :class="dropdownIcon" v-bind="ptm('dropdownButtonIcon')" /> <component :is="dropdownIcon ? 'span' : 'ChevronDownIcon'" :class="dropdownIcon" v-bind="ptm('dropdownButtonIcon')" />
</slot> </slot>
@ -112,6 +123,7 @@
<div <div
v-if="overlayVisible" v-if="overlayVisible"
:ref="overlayRef" :ref="overlayRef"
:id="panelId"
:class="[cx('panel'), panelClass]" :class="[cx('panel'), panelClass]"
:style="{ ...panelStyle, 'max-height': virtualScrollerDisabled ? scrollHeight : '' }" :style="{ ...panelStyle, 'max-height': virtualScrollerDisabled ? scrollHeight : '' }"
@click="onOverlayClick" @click="onOverlayClick"
@ -943,6 +955,9 @@ export default {
}, },
virtualScrollerDisabled() { virtualScrollerDisabled() {
return !this.virtualScrollerOptions; return !this.virtualScrollerOptions;
},
panelId() {
return this.id + '_panel';
} }
}, },
components: { components: {