Akryum / vue-virtual-scroller

⚡️ Blazing fast scrolling for any amount of data
https://vue-virtual-scroller-demo.netlify.app
9.27k stars 885 forks source link

`scrollToItem` conflicts with `gridItems` #773

Closed homersimpsons closed 1 year ago

homersimpsons commented 1 year ago

Describe the bug

A call to scrollToItem require the user to set a value for gridItems:

https://github.com/Akryum/vue-virtual-scroller/blob/86fa98fd899487795b2d3c58d0486437d71c6892/packages/vue-virtual-scroller/src/components/RecycleScroller.vue#L681-L689

Doing so, the library set a width to the items in px and that is by default the same as the itemSize:

https://github.com/Akryum/vue-virtual-scroller/blob/86fa98fd899487795b2d3c58d0486437d71c6892/packages/vue-virtual-scroller/src/components/RecycleScroller.vue#LL35C2-L35C11

This breaks list where the item width is 100%

Reproduction

<template>
  <div id="app">
    <RecycleScroller
      :items="items"
      v-slot="{ item }"
      :grid-items="1"
      :item-size="20"
    >
      <div height="20">{{ item.id }} This takes more than 20px witdh</div>
    </RecycleScroller>
  </div>
</template>

<script>
export default {
  setup() {
    return {
      items: [...Array(1000).keys()].map((x) => ({ id: x })),
    };
  },
};
</script>

https://stackblitz.com/edit/vue-zcyqsm?file=src/App.vue

System Info

NA (stackblitz)

Used Package Manager

yarn

Validations

wchbrad commented 1 year ago

Hello, when will the fix version for this issue be released, components that depend on this will not work properly for now .Thank you for your reply.