vue-virtual-scroller icon indicating copy to clipboard operation
vue-virtual-scroller copied to clipboard

Index is non-reactive (@next)

Open ishitatsuyuki opened this issue 3 years ago • 4 comments

In the next branch, the index passed to the slot is from the non-reactive field:

https://github.com/Akryum/vue-virtual-scroller/blob/a6e07da79af0165a62fc6fc9bfb8ca08631b25ef/packages/vue-virtual-scroller/src/components/RecycleScroller.vue#L37

I'm seeing that my index-based view widget shows stale element, and I'm assuming that this is caused by this non-reactiveness.

Can you confirm that it can cause updates to be skipped for any index-based computed/templates, and if that's the case, make it properly reactive?

ishitatsuyuki avatar Jun 24 '22 07:06 ishitatsuyuki

It looks like reactivity isn't really the issue here, but the recycling logic is simply a little too overengineered and decides to reuse an element with a key that doesn't match (or otherwise corrupt internal state). I have locally done a rewrite to simplify the logic to resolve the issue, and I plan to file a PR later.

ishitatsuyuki avatar Jun 24 '22 09:06 ishitatsuyuki

pr? im having similar issue. im getting stale data when i change the data

patchthecode avatar Aug 25 '22 00:08 patchthecode

See https://github.com/Akryum/vue-virtual-scroller/pull/743.

ishitatsuyuki avatar Aug 25 '22 00:08 ishitatsuyuki

I think I'm getting the same issue. If I keep changing the data sent to items, after a while, the index exposed in the v-slot="{ item, index }" will be outdated and I will get an index related to previous data. Sometimes my items array has a length of 4, and I'm getting that the latest item has the index of 8 for example (related to previous data when my array had a length of 9

fidalgodev avatar Jan 13 '23 11:01 fidalgodev