Fixed #2158 - MultiSelect virtual scroll with selected item

pull/2161/head
Tuğçe Küçükoğlu 2022-02-14 16:09:35 +03:00 committed by Tuğçe Küçükoğlu
parent 63e8f54e2f
commit 694ff34bf4
1 changed files with 12 additions and 8 deletions

View File

@ -28,7 +28,7 @@
</slot> </slot>
</div> </div>
<Teleport :to="appendTarget" :disabled="appendDisabled"> <Teleport :to="appendTarget" :disabled="appendDisabled">
<transition name="p-connected-overlay" @enter="onOverlayEnter" @leave="onOverlayLeave" @after-leave="onOverlayAfterLeave"> <transition name="p-connected-overlay" @enter="onOverlayEnter" @after-enter="onOverlayAfterEnter" @leave="onOverlayLeave" @after-leave="onOverlayAfterLeave">
<div :ref="overlayRef" :class="panelStyleClass" v-if="overlayVisible" @click="onOverlayClick"> <div :ref="overlayRef" :class="panelStyleClass" v-if="overlayVisible" @click="onOverlayClick">
<slot name="header" :value="modelValue" :options="visibleOptions"></slot> <slot name="header" :value="modelValue" :options="visibleOptions"></slot>
<div class="p-multiselect-header" v-if="(showToggleAll && selectionLimit == null) || filter"> <div class="p-multiselect-header" v-if="(showToggleAll && selectionLimit == null) || filter">
@ -420,6 +420,17 @@ export default {
onOverlayEnter(el) { onOverlayEnter(el) {
ZIndexUtils.set('overlay', el, this.$primevue.config.zIndex.overlay); ZIndexUtils.set('overlay', el, this.$primevue.config.zIndex.overlay);
this.alignOverlay(); this.alignOverlay();
if (!this.virtualScrollerDisabled) {
const selectedIndex = this.getSelectedOptionIndex();
if (selectedIndex !== -1) {
setTimeout(() => {
this.virtualScroller && this.virtualScroller.scrollToIndex(selectedIndex)
}, 0);
}
}
},
onOverlayAfterEnter() {
this.bindOutsideClickListener(); this.bindOutsideClickListener();
this.bindScrollListener(); this.bindScrollListener();
this.bindResizeListener(); this.bindResizeListener();
@ -428,13 +439,6 @@ export default {
this.$refs.filterInput.focus(); this.$refs.filterInput.focus();
} }
if (!this.virtualScrollerDisabled) {
const selectedIndex = this.getSelectedOptionIndex();
if (selectedIndex !== -1) {
this.virtualScroller.scrollToIndex(selectedIndex);
}
}
this.$emit('show'); this.$emit('show');
}, },
onOverlayLeave() { onOverlayLeave() {