Open johankvint opened 8 years ago
And all id's are unique? Seems like an edge case issue when doing prepending to the masonry.. Might be that the "algorithm" for diffing does not account for this. What happens if you always include a dummy element at the top that is "invisible"?
@cybercomkvint can you please try the 3.0.0 beta and see if it fixes things for you?
npm install --save react-masonry-component@3.0.0-rc.1
You no longer need to pass in React to a function - also a little extra setup required if using Webpack. More info in Readme
I had the same problem and can confirm using 3.0.0-rc.1
does not fix it. However using a dummy element does fix it. Quite odd..
I am using a div with width 1px and height 0px which surprisingly does the trick. If I use an empty div with no styling, it causes all the masonry elements to be stacked vertically despite having plenty of space to be layed out horizontally.
Also hit this buglet. Same situation, I have a list of items and the ability to filter the set. When going from a filtered view to the "All Items" view, I end up with stacking, empty space in first row. I spent time trying to "kick" masonry to re-layout in componentDidUpdate (didn't work), then tried calling masonry.layout() in a setTimer(). No work.
I next did the horrible thing of making my element array key properties always random. that fixed it, but had unwanted side-effects for certain other modal views.
Adding the empty div
as first element of every filtered view solved the problem.
Thank god I saw this issue, was trying to figure out what's happening with my layout with filtering involved. Hacked with div height 1 width 1 just the same.
I have an array with elements that I get from filtering a larger array base on some value. I give the children to the masonry unique keys. This works great when the visible child at position 0 in array remains visible all the time. But when a child gets prepended in the array the child elements start to overlap.