[Masonry] Doesn't respond to resize of the container, broke in 5.0.0-alpha.64

Open
#31,031 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, react
Domain
frontend

Research direction

Start by examining the Masonry component's useEffect and the ResizeObserver setup, comparing the change described in commit 8e4c482d99. Verify that resizing the parent container causes the column count to recalculate, including when no child changes, and confirm the behavior against a focused test or reproduction.

Written by the indexing model from the issue text.

Description

scope: masonry type: bug
Duplicates
  • I have searched the existing issues
Latest version
  • I have tested the latest version
Current behavior 😯

I've been using <Masonry columns={1} > and when the container is wide enough, this control has been great at automagically creating more columns when the container is wide enough. And likewise if I start with a large container and make it smaller, it would auto-decrease the number of columns to make everything fit.

Since upgrading to latest version, alpha.68, Masonry correctly calculates number of columns to start with but then no matter how much you resize the window, it will never change the column count like it used to.

Expected behavior 🤔

I'd expect when the parent container is resized, Masonry would auto-adjust number of columns it is displaying

Steps to reproduce 🕹

No response

Context 🔦

I'm looking at the diff between commit 8e4c482d99, "observe every masonry child to trigger computation when needed" and it appears that inside useEffect() where in the past resizeObserver used to be hooked up to the container and the first child, the change was done to loop through all the children, not just the first one, but I think container was inadvertently missed so now unless one of the children changes, resizeHandler never gets invoked.

Your environment 🌎

No response

Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mui/material-ui

All issues in mui/material-ui

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.