-
Notifications
You must be signed in to change notification settings - Fork 13.5k
bug: ion-virtual-scroll overlapping items #18409
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
Comments
Confirmed, this is still an issue in 4.6.0 AND dev |
Seems like the code path for stencil usage never measures the elements. I tried hacking at it for a bit, but it only works once after the first scroll event, then things get janked up. this.el.forceUpdate();
this.virtualDom.forEach((node: any) => {
const domNode: any = this.el.children[node.cell.i - this.range.offset];
if (!domNode) { return; }
const update = () => {
const style = window.getComputedStyle(domNode);
const height = domNode.offsetHeight + parseFloat(style.getPropertyValue('margin-bottom'));
this.setCellHeight(node.cell, height);
};
domNode && domNode.componentOnReady ? node.componentOnReady().then(update) : update();
}); |
In version 4.6.2, ion-virtual-scroll still has issues. In fact, the update seems to have broken a working ion-virtual-scroll. I decided to dig in a bit to see if I could isolate the problem since I seem to perpetually have ion-virtual-scroll issues like this: My code:
How it renders: (Note that there are 6 cards instead of 11 showing) Tried switching to items instead of cards, which helped, but I'm trying to use cards. Not items. Added a console.log() in: The height should be 18px for each. The solution for me, for the time being, was to put the ion-card inside of an ion-item. This is especially ironic since the documentation for ion-virtual-scroll gives the example using a card: Hope all of this helps someone find the source of this issue and resolve this once and for all. I feel like I've spent more time debugging ion-virtual-scroll since (I think) ionic v1, than debugging anything else in ionic. |
You may want to watch or join in on #16632 - it lists a lot of related bugs. |
I am also facing this overlapping problem. :/ any workaround for fix for this problem
|
Same Issue. Its been a long one and had not been fixed for years #11542 Can we fix this after 3 years? |
Well it's still with us in Version 5 :-( They are aware that Virtual Scroll is broken. I'm hoping it will be fixed this year else we are looking at a V6 fix, I'm not quite sure what to read from the following video about V5 at '30:41' when @brandyscarney says "Are we allowed to mention Virtual Scroll?' in response to beginning to talk about V6. I'm hoping she's suggesting it may come before hand. https://www.youtube.com/watch?v=eegTEIRDlhg However when I spoke to Ionic support Mid 2019 they suggested that they were looking at Angular's virtual scroll and had found that the manner in which it works would fit better into the ecosystem. This suggests to me there may be an API breaking change coming in V6. Ionic pointed me towards the following: https://github.com/mhartington/cdk-virtual-scroll-ionic I've not looked into this as a replacement yet, as we are not near release and are ignoring the overlap for now, preying it will be fixed. If anyone does try Angular's solution and it solves this issue please post here so that others can gain confidence to go give it a go. |
I have reproduced the bug with v5. I think that the problem is that ion-virtual-scroll uses an internal list called "heightIndex" which contains the height of every item inside. I'm not an ionic expert but I think i have found a workaround by using ionImgDidLoad. Maybe there is a cleaner solution but I hope it helps. In page.html
In page.ts
|
@dmunicio are you able to get the index of the list with the help of let i = index ? |
Yes, if you run that code, you can see the output of console.log(i) while making scroll. |
This issue is majorly affecting my app. Does anyone have a solid alternative to the virtual scroll card combo? |
It seems like using a regular |
I have been using |
Hi everyone this is my fix/workaround for this problem:
|
It showing then duplicate/old data when Array is changed. |
Is anyone fixed this? I tried to use img but it gives me another issue which it will show the wrong image until the new is loaded |
No. I tried also all work arounds, it always giving an issue. One finished then another started. So finally I am using for scroll https://material.angular.io/cdk/scrolling/overview |
Sad there is still no feedback here, having the same issue |
We started seeing this issue as well, randomly, and may have narrowed down a culprit. It seems to be when the native keyboard opens up that our virtual scroll has either scrunched up a bunch of overlapping items if at the top of the virtual scroll, or a blank virtual scroll if it was already scrolled down a bit. My guess is the viewport is getting relocated/resized, throwing off the virtual scroll's positioning math. Hope this helps! |
Same problem here on ionic 5... |
Guys, I don't think it's not gonna fix! This bug is there from decades. Stop making hope just use angular virtual scroll (https://material.angular.io/cdk/scrolling/overview) |
Yes, this is not working with a very simple use case too. i.e. no images, no dynamic size changes and etc. Just around 500 items only
|
This workaround works for me: style="min-height: 150px!important; max-height: 300px!important;"
|
didn't worked for me ... It create strange spaces between the items |
So far i found this solution which is working for me
|
I've tried the resize event aswell, and it fixed about 80% of the time those issues. My solution was to swap to: I've tried multiple virtuell scroll plugins, and this was the only one which could handle dynamic heights and is very fast. |
Thanks for mentioning another way of doing for special cases where the items have dynamic height , But in my case with my solution with dynamic height of items it will working without any issues ,but then i have to check more to see then i will check this plugin. |
where you add this code? can you do a example please? i have the same problem, each item has a different height, and every 50-100 items happen that these overlap |
Thanks for the issue! With the release of Ionic 6, we made the decision to deprecate Moving forward, We have prepared migration guides for each of the 3 JavaScript frameworks we support, so developers can get started migrating right away. Migration for Angular Some Ionic components that rely on scrolling inside of We believe this change will lead to a healthier Ionic ecosystem as it frees up resources for the Ionic team to dedicate to other areas of this project while still giving developers options for performant virtual scroll solutions. Thank you! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Bug Report
Ionic version:
4.4
Current behavior:
When using a virtual scroll component containing items of varying height with an infinite scroll occasionally the height of some items is approxItemHeight instead of calculating the height which causes overlapping.
Expected behavior:
It should be possible to have items of varying heights within a virtual scroll component when using infinite-scroll.
Steps to reproduce:
I've created a simple test app with which you can reproduce the issue. It's available here: https://github.com/andsee/Ionic-Virtual-Scroll-Overlap-Bug
Run in chrome while inspecting in a portrait iPhone X and scroll down, keep scrolling until you see some overlapping. Note I've set the approxItemHeight to just 10px as this makes it easier to reproduce, it still occurs with larger approximations. Occasionally I've had to scroll down to item 200+, other times it happens quickly. It's probably to do with the speed at which you scroll.
Here is a video of it occurring:
https://youtu.be/uu_R5L7KIOE
Related code:
Full project allowing repro: https://github.com/andsee/Ionic-Virtual-Scroll-Overlap-Bug
Other information:
Ionic info:
The text was updated successfully, but these errors were encountered: