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

Space between items in the list is wrong #749

Closed
dragos-boisteanu opened this issue Sep 27, 2022 · 12 comments
Closed

Space between items in the list is wrong #749

dragos-boisteanu opened this issue Sep 27, 2022 · 12 comments

Comments

@dragos-boisteanu
Copy link

dragos-boisteanu commented Sep 27, 2022

Hi,

I am using the DynamicScroller for a chat app. When I add new items the space between them is not even close as it should be.

image

After I destroy and re-creeate the component(page refresh or v-if) it looks well:
image

Something similar happens when I add items at the top.

I am using Vue 2 and vue-virtual-scroller version 1.0.10

Any solution for this problem ?
Thank you

@nicholascloud
Copy link

I am having this same issue with the RecycleScroller.

Vue3 + [email protected].

The issue seems intermittent. Sometimes pages render correctly, other times a "space" appears between pages. The space is not actually an empty item, but the result of how item positions are calculated.

@ihapitw
Copy link

ihapitw commented Sep 28, 2022

Same problem

@ghimisradu
Copy link

We're having the same problem when the items in the scroller are expandable items(like a tree). Expanding let's say first item and scrolling to the bottom and expanding the last item will result in an empty space where the first item it's expanded.
It seems that the scroll it's not recalculating the sizes correctly (DynamicScroller)

@mattia-palmieri
Copy link

Same problem with vue-virtual-scroller 1.0.10 and DynamicScroller

@bleto
Copy link

bleto commented Sep 30, 2022

Version: 1.0.10

Hi, I have that same problem in DynamicScroller component.
There are empty spaces in the list, reserved for the missing element, but the data is not in the component.

Zrzut ekranu 2022-09-30 o 13 54 32

Code usage:

            <DynamicScroller
                :items="expandedItems"
                :key-field="optionKey"
                :prerender="prerender"
                :min-item-size="estimatedHeight">
                <template #default="{ item, index, active }">
                    <DynamicScrollerItem
                        :item="item"
                        :active="active"
                        :index="index">
                        <slot
                            name="item"
                            :index="index"
                            :item="item"
                            :on-expand="onExpandItem" />
                    </DynamicScrollerItem>
                </template>
            </DynamicScroller>

I noticed that the problem occurs with duplicate values, because in my case the invisible element is already displayed in the list (element "ccc").
An array of values is passed to display, but fewer elements are returned in the default scoped slot.

@mmouterde
Copy link

Same issue here.
Thanks to @bleto, I fix it removing unexpected duplicate values.

@dragos-boisteanu
Copy link
Author

dragos-boisteanu commented Oct 10, 2022

In my app I don't have duplicates. But the items have 2 keys, 1 is an id that is set when the item is added to the list, after the message is sent to the server the server response with a key called seq that I set for the message. The :key-field is set to seq.
Could this be the problem because I don't have a seq when the item is first added to the list ?

EDIT: this wasn't the problem, the items still have that wrong space between them

@Akryum
Copy link
Owner

Akryum commented Oct 17, 2022

Could you update vue-virtual-scroller and see if the problem still occurs? A lot of bug fixes shipped

@dragos-boisteanu
Copy link
Author

I updated it and now it works. Thank you a lot. This is the best virtual scroller I found.

Now, there is still a problem. My objects from the list are like this:

const obj = {
  id: null, 
  seq: 123,
  ...otherFields
}

If I set the keyField prop to 'seq' it will say that the 'seq' is an undefined field in the item object. The item object has the id field that has the same value as the seq field from my object and another field item that is my object, but no seq(the keyField) field. You can see more details in the images bellow.

I found a way to make it work by doing obj.id = obj.seq before obj is added to the list of items. It works, but it doesn't feel right.

image
image
image

@Akryum
Copy link
Owner

Akryum commented Oct 17, 2022

@dragos-boisteanu Could you open a new issue with a runnable reproduction so I can look at your problem? Thanks! 🙏

@dragos-boisteanu
Copy link
Author

@dragos-boisteanu Could you open a new issue with a runnable reproduction so I can look at your problem? Thanks! 🙏

You can find it here: #758

@Akryum
Copy link
Owner

Akryum commented Oct 18, 2022

Please open a new issue if you still see wrong item sizes with the latest releases

@Akryum Akryum closed this as completed Oct 18, 2022
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

8 participants