-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
[ImageItemList] Fix incorrect (below) rendering #38452
[ImageItemList] Fix incorrect (below) rendering #38452
Conversation
Netlify deploy previewhttps://deploy-preview-38452--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be great if you do not add this thing into this arrow function.
Where do you think that is should be? |
|
Hey @omriklein, thanks for working on this 🎉 I will add the link to the issue in the PR description. May I ask you to explain why this fixes the issue? I see it fixes it, but I don't understand why. We can't merge this PR as is because the Woven example breaks (docs vs. this PR). That's why I want to try and understand the underlying issue so we can develop a proper solution. |
It appears that adding const ImageListItemRoot = styled('li', {
...
})(({ ownerState }) => ({
...
display: 'block',
position: 'relative',
- overflow: 'hidden',
...
}));
...
<ImageListItemRoot
...
style={{
height,
gridColumnEnd: variant !== 'masonry' ? `span ${cols}` : undefined,
gridRowEnd: variant !== 'masonry' ? `span ${rows}` : undefined,
marginBottom: variant === 'masonry' ? gap : undefined,
+ display: variant === 'masonry' ? 'inline-block' : undefined,
...style,
}}
...
</ImageListItemRoot> So it prevents the immediate children of the |
@DiegoAndai The @cristianmacedo This seems like a good solution, I'll check this out. Thanks |
@cristianmacedo I tried your solution but the I expect the images to show side by side and not one on top of the other. |
Adding the
I understand that. Why did clipping the content cause it to be correctly placed? Why, when the content is not clipped, it's placed in column two, but when it's clipped, it's still visible and placed in column one.
Can you share an example of the code you're using that is not fixed by adding |
@DiegoAndai It seems to be a more general problem with HTML & CSS. I'm yet to figure out exactly why only The most basic example of this bug is as follows: <!DOCTYPE html>
<html lang="en">
<body>
<ul class="list">
<li class="item">
<div>text 1</div>
<div>text 2</div>
</li>
</ul>
</body>
<style>
.list{
column-count: 2;
}
.item{
overflow: hidden; /* Without this line, the bug happens */
}
</style>
</html> |
@omriklein, thanks for the minimal example of the bug. It is indeed a weird behavior. I investigated, and #33593 introduced this issue. Changing from The root cause is that the container height is not calculated properly. This code sandbox example shows that by adding a red border to the container. What do you think about using |
@DiegoAndai Thank you! The break-inside: avoid did the job. I updated the code accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @omriklein! 🎉
Nice, this PR relies on the same CSS property that I used in #36673 (comment). @DiegoAndai I polished a bit the issue/PR titles, labels, descriptions. |
Closes: #38341 (comment)
Before: https://mui.com/material-ui/react-image-list/#title-bar-below-image-masonry
Preview: https://deploy-preview-38452--material-ui.netlify.app/material-ui/react-image-list/#title-bar-below-image-masonry