-
-
Notifications
You must be signed in to change notification settings - Fork 300
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
[BUG] Items get calculated incorrectly when child of flex parent #522
Comments
I will note that the example codesandbox I linked to where it seemed to be working is using version 0.12.0, while my codesandbox is using 2.2.7 (and I've been able to reproduce up to the latest version). But if I update the example (not in a popover) to latest, it still does not reproduce the issue. It seems I'm only seeing this in a popover, so I'm not sure what's different. |
Actually, I took the time to go through the versions of react-virtuoso in my codesandbox, and it seems the issue starts showing up with v1.10.7. The version before that, v.1.10.6, does not seem to have scrolling or gap issues. |
v1.10.7 switched from using offsetHeight to using It's unlikely for me to investigate that in a reasonable timeframe, especially given that it needs mui for reproduction (which in general has a lot going on in terms of styles and positioning). If you're looking for a workaround, you can try overriding |
So yeah, it's definitely not getting the right height on mount. Here's what this looks like in my own code: Above is what the elements look like in the DOM, but here's what Virtuoso thinks about the first one: Interestingly, if I click any of the checkboxes, causing a re-render of the Virtuoso, it updates the |
Actually, one thing above is incorrect: in |
I'm not sure if the green part from the above is a margin - if so, it will confuse the layout a lot. offsetHeight does not include it. |
I'm fairly certain it's padding. I tried to clear margins. |
@petyosi, I determined what the issue is. It appears to be due to the fact that the Material UI Popover animates a transition when it enters. The Virtuoso tries to grab dimensions while the Popover is transitioning and gets incorrect information. If I defer the rendering of the Virtuoso until the Popover has fully entered, the Virtuoso works correctly. So this is not an issue with Virtuoso. I just wanted to add the update here for anyone else who happens upon this issue and wonders what the problem was. If I come up with working code I'll try to update with a codesandbox. I did a really dirty hack in my testing where I just did a |
Did you manage to do it in a nicer way? I have the exact same issue :) |
@trainoasis - I think I ended up moving away from Popover to using Popper and didn't have the same issue. I may have also moved away from flex display. I don't remember exactly, unfortunately. I've also since upgraded MUI and a lot of other libraries. |
@trainoasis Hi , facing a similar issue , any luck with the solution ? |
Describe the bug
This may be a bug, or it may be incorrect usage. I am using Virtuoso inside a Material UI Popover, and placing it inside a flex container so it takes up the remaining portion of the popover after some content (see codesandbox link). My understanding is I should be able to have a structure like this:
And it seems this works just fine when this is just in the regular DOM, as shown in the codesandbox here. But when I put it in a Popover with this same sort of structure, it doesn't seem to be able to calculate the right number of items to show, and you'll notice when scrolling to the bottom of the list there's a gap and not all of them render.
Reproduction
https://codesandbox.io/s/vigilant-rgb-xugwm?file=/src/components/App.js
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Should render all items with no gap at the bottom
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: