GithubHelp home page GithubHelp logo

Comments (4)

DiegoAndai avatar DiegoAndai commented on August 15, 2024

Hey @Fanzzzd, thanks for the report!

May I ask you to share the code of the live example? If you could share the stackblitz in editor mode, that would be great. This will help us understand the issue better.

from material-ui.

mbrookes avatar mbrookes commented on August 15, 2024

Interestingly it only affects the initial layout. It's fine if it's hidden after it's rendered. (Literally "turn it off and on again" in dev-tools.)

https://stackblitz.com/edit/react-hhacxp?file=Demo.tsx

from material-ui.

Fanzzzd avatar Fanzzzd commented on August 15, 2024

Hi @DiegoAndai ,

Here is the editor link to the live example: https://stackblitz.com/edit/react-nxweja?file=Demo.tsx

I observed the same behavior as @mbrookes mentioned. Once the Masonry layout is loaded, setting any element to display: none does not affect the layout.

Issue Analysis:
The issue where the Masonry layout forms a single column when the first item is hidden initially occurs because the layout calculations are based on the first child element. If this element is hidden, its height is zero, which triggers the skip condition. This condition is intended to handle cases where images havenโ€™t loaded yet but also inadvertently causes problems when the first element is simply hidden.

Solution:
I modified the code to identify the first visible child instead of assuming the first child is visible. This ensures that the layout calculations use a visible element, avoiding the height zero issue. Additionally, I added checks to skip any children that are not visible during layout calculations, preventing them from affecting the layout logic.

With these changes, the Masonry layout should initialize correctly even if the initial item is hidden. If you like you can give it a try and plz let me know if it works!

from material-ui.

DiegoAndai avatar DiegoAndai commented on August 15, 2024

Thanks for the live example @Fanzzzd. Accepted as a bug.

from material-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.