AutoComplete option list scroll behavior fixes
parent
0125015937
commit
dc34e05a1b
|
@ -190,6 +190,10 @@ export interface AutoCompletePassThroughOptions {
|
||||||
* @see {@link VirtualScrollerPassThroughOptionType}
|
* @see {@link VirtualScrollerPassThroughOptionType}
|
||||||
*/
|
*/
|
||||||
virtualScroller?: VirtualScrollerPassThroughOptionType;
|
virtualScroller?: VirtualScrollerPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Used to pass attributes to the list container's DOM element.
|
||||||
|
*/
|
||||||
|
listContainer?: AutoCompletePassThroughOptionType;
|
||||||
/**
|
/**
|
||||||
* Used to pass attributes to the list's DOM element.
|
* Used to pass attributes to the list's DOM element.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -121,22 +121,21 @@
|
||||||
</span>
|
</span>
|
||||||
<Portal :appendTo="appendTo">
|
<Portal :appendTo="appendTo">
|
||||||
<transition name="p-connected-overlay" @enter="onOverlayEnter" @after-enter="onOverlayAfterEnter" @leave="onOverlayLeave" @after-leave="onOverlayAfterLeave" v-bind="ptm('transition')">
|
<transition name="p-connected-overlay" @enter="onOverlayEnter" @after-enter="onOverlayAfterEnter" @leave="onOverlayLeave" @after-leave="onOverlayAfterLeave" v-bind="ptm('transition')">
|
||||||
<div
|
<div v-if="overlayVisible" :ref="overlayRef" :id="panelId" :class="[cx('overlay'), panelClass, overlayClass]" :style="{ ...panelStyle, ...overlayStyle }" @click="onOverlayClick" @keydown="onOverlayKeyDown" v-bind="ptm('overlay')">
|
||||||
v-if="overlayVisible"
|
|
||||||
:ref="overlayRef"
|
|
||||||
:id="panelId"
|
|
||||||
:class="[cx('overlay'), panelClass, overlayClass]"
|
|
||||||
:style="{ ...panelStyle, ...overlayStyle, 'max-height': virtualScrollerDisabled ? scrollHeight : '' }"
|
|
||||||
@click="onOverlayClick"
|
|
||||||
@keydown="onOverlayKeyDown"
|
|
||||||
v-bind="ptm('overlay')"
|
|
||||||
>
|
|
||||||
<slot name="header" :value="modelValue" :suggestions="visibleOptions"></slot>
|
<slot name="header" :value="modelValue" :suggestions="visibleOptions"></slot>
|
||||||
|
<div :class="cx('listContainer')" :style="{ 'max-height': virtualScrollerDisabled ? scrollHeight : '' }" v-bind="ptm('listContainer')">
|
||||||
<VirtualScroller :ref="virtualScrollerRef" v-bind="virtualScrollerOptions" :style="{ height: scrollHeight }" :items="visibleOptions" :tabindex="-1" :disabled="virtualScrollerDisabled" :pt="ptm('virtualScroller')">
|
<VirtualScroller :ref="virtualScrollerRef" v-bind="virtualScrollerOptions" :style="{ height: scrollHeight }" :items="visibleOptions" :tabindex="-1" :disabled="virtualScrollerDisabled" :pt="ptm('virtualScroller')">
|
||||||
<template v-slot:content="{ styleClass, contentRef, items, getItemOptions, contentStyle, itemSize }">
|
<template v-slot:content="{ styleClass, contentRef, items, getItemOptions, contentStyle, itemSize }">
|
||||||
<ul :ref="(el) => listRef(el, contentRef)" :id="id + '_list'" :class="[cx('list'), styleClass]" :style="contentStyle" role="listbox" :aria-label="listAriaLabel" v-bind="ptm('list')">
|
<ul :ref="(el) => listRef(el, contentRef)" :id="id + '_list'" :class="[cx('list'), styleClass]" :style="contentStyle" role="listbox" :aria-label="listAriaLabel" v-bind="ptm('list')">
|
||||||
<template v-for="(option, i) of items" :key="getOptionRenderKey(option, getOptionIndex(i, getItemOptions))">
|
<template v-for="(option, i) of items" :key="getOptionRenderKey(option, getOptionIndex(i, getItemOptions))">
|
||||||
<li v-if="isOptionGroup(option)" :id="id + '_' + getOptionIndex(i, getItemOptions)" :style="{ height: itemSize ? itemSize + 'px' : undefined }" :class="cx('optionGroup')" role="option" v-bind="ptm('optionGroup')">
|
<li
|
||||||
|
v-if="isOptionGroup(option)"
|
||||||
|
:id="id + '_' + getOptionIndex(i, getItemOptions)"
|
||||||
|
:style="{ height: itemSize ? itemSize + 'px' : undefined }"
|
||||||
|
:class="cx('optionGroup')"
|
||||||
|
role="option"
|
||||||
|
v-bind="ptm('optionGroup')"
|
||||||
|
>
|
||||||
<slot name="optiongroup" :option="option.optionGroup" :index="getOptionIndex(i, getItemOptions)">{{ getOptionGroupLabel(option.optionGroup) }}</slot>
|
<slot name="optiongroup" :option="option.optionGroup" :index="getOptionIndex(i, getItemOptions)">{{ getOptionGroupLabel(option.optionGroup) }}</slot>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
|
@ -170,6 +169,7 @@
|
||||||
<slot name="loader" :options="options"></slot>
|
<slot name="loader" :options="options"></slot>
|
||||||
</template>
|
</template>
|
||||||
</VirtualScroller>
|
</VirtualScroller>
|
||||||
|
</div>
|
||||||
<slot name="footer" :value="modelValue" :suggestions="visibleOptions"></slot>
|
<slot name="footer" :value="modelValue" :suggestions="visibleOptions"></slot>
|
||||||
<span role="status" aria-live="polite" class="p-hidden-accessible" v-bind="ptm('hiddenSelectedMessage')" :data-p-hidden-accessible="true">
|
<span role="status" aria-live="polite" class="p-hidden-accessible" v-bind="ptm('hiddenSelectedMessage')" :data-p-hidden-accessible="true">
|
||||||
{{ selectedMessageText }}
|
{{ selectedMessageText }}
|
||||||
|
|
|
@ -54,6 +54,10 @@ export enum AutoCompleteClasses {
|
||||||
* Class name of the list element
|
* Class name of the list element
|
||||||
*/
|
*/
|
||||||
list = 'p-autocomplete-list',
|
list = 'p-autocomplete-list',
|
||||||
|
/**
|
||||||
|
* Class name of the list container element
|
||||||
|
*/
|
||||||
|
listContainer = 'p-autocomplete-list-container',
|
||||||
/**
|
/**
|
||||||
* Class name of the option group element
|
* Class name of the option group element
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -84,6 +84,10 @@ const theme = ({ dt }) => `
|
||||||
box-shadow: ${dt('autocomplete.overlay.shadow')};
|
box-shadow: ${dt('autocomplete.overlay.shadow')};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.p-autocomplete-list-container {
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.p-autocomplete-list {
|
.p-autocomplete-list {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -278,6 +282,7 @@ const classes = {
|
||||||
loader: 'p-autocomplete-loader',
|
loader: 'p-autocomplete-loader',
|
||||||
dropdown: 'p-autocomplete-dropdown',
|
dropdown: 'p-autocomplete-dropdown',
|
||||||
overlay: 'p-autocomplete-overlay p-component',
|
overlay: 'p-autocomplete-overlay p-component',
|
||||||
|
listContainer: 'p-autocomplete-list-container',
|
||||||
list: 'p-autocomplete-list',
|
list: 'p-autocomplete-list',
|
||||||
optionGroup: 'p-autocomplete-option-group',
|
optionGroup: 'p-autocomplete-option-group',
|
||||||
option: ({ instance, option, i, getItemOptions }) => [
|
option: ({ instance, option, i, getItemOptions }) => [
|
||||||
|
|
Loading…
Reference in New Issue