From 2f3c210a8ea0c06ea8e1e4dcb18b60cd81df8c2b Mon Sep 17 00:00:00 2001 From: mertsincan Date: Thu, 30 Jun 2022 22:38:07 +0100 Subject: [PATCH] Fixed #2715 - DropDown: Filter with Virtual Scroll does not work as expected --- src/components/dropdown/Dropdown.vue | 2 ++ src/components/virtualscroller/VirtualScroller.vue | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/dropdown/Dropdown.vue b/src/components/dropdown/Dropdown.vue index 7bb9e4f4a..8efb3fdb2 100755 --- a/src/components/dropdown/Dropdown.vue +++ b/src/components/dropdown/Dropdown.vue @@ -617,6 +617,8 @@ export default { onFilterChange(event) { this.filterValue = event.target.value; this.$emit('filter', {originalEvent: event, value: event.target.value}); + + !this.virtualScrollerDisabled && this.virtualScroller.scrollToIndex(0); }, onFilterUpdated() { if (this.overlayVisible) { diff --git a/src/components/virtualscroller/VirtualScroller.vue b/src/components/virtualscroller/VirtualScroller.vue index 90573890e..b169e9c54 100644 --- a/src/components/virtualscroller/VirtualScroller.vue +++ b/src/components/virtualscroller/VirtualScroller.vue @@ -143,6 +143,7 @@ export default { return this.orientation === 'both'; }, scrollTo(options) { + this.lastScrollPos = this.isBoth() ? { top: 0, left: 0 } : 0; this.element && this.element.scrollTo(options); }, scrollToIndex(index, behavior = 'auto') { @@ -160,7 +161,6 @@ export default { const newFirst = { rows: calculateFirst(index[0], numToleratedItems[0]), cols: calculateFirst(index[1], numToleratedItems[1]) }; if (newFirst.rows !== first.rows || newFirst.cols !== first.cols) { scrollTo(calculateCoord(newFirst.cols, itemSize[1], contentPos.left), calculateCoord(newFirst.rows, itemSize[0], contentPos.top)) - this.first = newFirst; } } else { @@ -168,7 +168,6 @@ export default { if (newFirst !== first) { horizontal ? scrollTo(calculateCoord(newFirst, itemSize, contentPos.left), 0) : scrollTo(0, calculateCoord(newFirst, itemSize, contentPos.top)); - this.first = newFirst; } } },