From 694ff34bf41938c331b00825033c0cf263985d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Mon, 14 Feb 2022 16:09:35 +0300 Subject: [PATCH] Fixed #2158 - MultiSelect virtual scroll with selected item --- src/components/multiselect/MultiSelect.vue | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/multiselect/MultiSelect.vue b/src/components/multiselect/MultiSelect.vue index 0700e94e1..9c8ccb338 100755 --- a/src/components/multiselect/MultiSelect.vue +++ b/src/components/multiselect/MultiSelect.vue @@ -28,7 +28,7 @@ - +
@@ -420,6 +420,17 @@ export default { onOverlayEnter(el) { ZIndexUtils.set('overlay', el, this.$primevue.config.zIndex.overlay); this.alignOverlay(); + + if (!this.virtualScrollerDisabled) { + const selectedIndex = this.getSelectedOptionIndex(); + if (selectedIndex !== -1) { + setTimeout(() => { + this.virtualScroller && this.virtualScroller.scrollToIndex(selectedIndex) + }, 0); + } + } + }, + onOverlayAfterEnter() { this.bindOutsideClickListener(); this.bindScrollListener(); this.bindResizeListener(); @@ -428,13 +439,6 @@ export default { this.$refs.filterInput.focus(); } - if (!this.virtualScrollerDisabled) { - const selectedIndex = this.getSelectedOptionIndex(); - if (selectedIndex !== -1) { - this.virtualScroller.scrollToIndex(selectedIndex); - } - } - this.$emit('show'); }, onOverlayLeave() {