Skip to content

Commit 395bbfb

Browse files
committed
fix: views incorrectly unused (proxy identity comparison)
1 parent 86fa98f commit 395bbfb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/vue-virtual-scroller/src/components/RecycleScroller.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ export default {
220220
},
221221
222222
simpleArray,
223+
224+
itemIndexByKey () {
225+
const { keyField, items } = this
226+
const result = {}
227+
for (let i = 0, l = items.length; i < l; i++) {
228+
result[items[i][keyField]] = i
229+
}
230+
return result
231+
},
223232
},
224233
225234
watch: {
@@ -373,6 +382,7 @@ export default {
373382
const views = this.$_views
374383
const unusedViews = this.$_unusedViews
375384
const pool = this.pool
385+
const itemIndexByKey = this.itemIndexByKey
376386
let startIndex, endIndex
377387
let totalSize
378388
let visibleStartIndex, visibleEndIndex
@@ -500,7 +510,7 @@ export default {
500510
if (view.nr.used) {
501511
// Update view item index
502512
if (checkItem) {
503-
view.nr.index = items.indexOf(view.item)
513+
view.nr.index = itemIndexByKey[view.item[keyField]]
504514
}
505515
506516
// Check if index is still in visible range

0 commit comments

Comments
 (0)