File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
packages/vue-virtual-scroller/src/components Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,15 @@ export default {
220
220
},
221
221
222
222
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
+ },
223
232
},
224
233
225
234
watch: {
@@ -373,6 +382,7 @@ export default {
373
382
const views = this .$_views
374
383
const unusedViews = this .$_unusedViews
375
384
const pool = this .pool
385
+ const itemIndexByKey = this .itemIndexByKey
376
386
let startIndex, endIndex
377
387
let totalSize
378
388
let visibleStartIndex, visibleEndIndex
@@ -500,7 +510,7 @@ export default {
500
510
if (view .nr .used ) {
501
511
// Update view item index
502
512
if (checkItem) {
503
- view .nr .index = items . indexOf ( view .item )
513
+ view .nr .index = itemIndexByKey[ view .item [keyField]]
504
514
}
505
515
506
516
// Check if index is still in visible range
You can’t perform that action at this time.
0 commit comments