Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useVirtualList is not updated immediately #3924

Closed
7 tasks done
Lazydd opened this issue Apr 15, 2024 · 4 comments
Closed
7 tasks done

useVirtualList is not updated immediately #3924

Lazydd opened this issue Apr 15, 2024 · 4 comments

Comments

@Lazydd
Copy link

Lazydd commented Apr 15, 2024

Describe the bug

Now scroll the scroll bar to the bottom, and then click the button. The newly added data does not appear. You need to scroll the scroll bar online and then scroll down before it appears.

Reproduction

https://stackblitz.com/edit/vitejs-vite-unw2xw?file=src%2FApp.vue,package.json

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700F
    Memory: 2.03 GB / 15.79 GB
  Binaries:
    Node: 18.18.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - C:\Program Files\nodejs\yarn.CMD
    npm: 9.8.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.11.0 - ~\node_modules\.bin\pnpm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @vueuse/components: ^10.9.0 => 10.9.0
    @vueuse/core: ^10.9.0 => 10.9.0
    vue: ^3.4.21 => 3.4.21

Used Package Manager

npm

Validations

@STY1997
Copy link

STY1997 commented May 31, 2024

I got the same issue, no idea how to fix this.

@STY1997
Copy link

STY1997 commented Jun 3, 2024

I solved this issue by using shallow copy instead of list.push, like: const myList = [...myList.value, newItem].
I am not sure why push may lose the reactivity in this scenario...
Not sure this would work for you, but this does work for me.

@crabcode
Copy link

crabcode commented Jun 3, 2024

It's been a while, but I believe you're able to call "containerProps.onScroll();" after any changes made and it will update. Too bad it needs this workaround though.

@windlil
Copy link

windlil commented Jun 5, 2024

Maybe you can try this and use reactive to make the array change responsive.

const allItems = reactive(Array.from(Array(99).keys()));
const filteredList = computed(() => {
  return allItems
});

@Lazydd Lazydd closed this as completed Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants