jaredLunde / jaredLunde/masonic

item width breaks with text wrap

Open
#172 4 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
TypeScript
Stars
1.4k
Forks
63
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
It appears the width calculation of each item breaks if the layout gives the masonry smaller available space, and gives it back afterwards. I've detected this with animations using framer-motion, see sandbox below. The masonry container appears to get the correct width. Also, triggering a rerender seems to fix the issue, but i don't know when to rerender in order to fix that.

**To Reproduce**
Hover over the nav bar, in order for it to grow. Then hover away and the masonry stays in the shrunk state
https://codesandbox.io/p/sandbox/frosty-framework-kfksfg

**Expected behavior**
The layout should adapt to wrapped/unwrapped text and calculate the width accordingly.

**Screenshots**

Before:
![image](https://github.com/user-attachments/assets/53ddecc8-87d5-40c1-919f-75601f1457f3)
After:
![image](https://github.com/user-attachments/assets/caefc44e-f3eb-48e8-82a7-0eb90cbe9c9f)

Contributor guide

Open the contributing guide

Research direction

Start by running the linked CodeSandbox and reproducing the nav hover resize with the masonry container. Trace how the layout responds when available width shrinks and expands; done means wrapped and unwrapped text produce the correct item widths without requiring an unrelated rerender.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.