jaredLunde / jaredLunde/masonic
Constant flicker on broken image
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 63
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
If any of the images higher up in the column are broken, the rest of the column starts flickering
**To Reproduce**
Sandbox here: https://codesandbox.io/p/sandbox/sparkling-cache-3cpp8v
(I'm not sure why some of the images are broken, but that seems to be a separate issue.)
**Expected behavior**
No flicker.
**Screenshots**

(Note that when live the column continues to flicker; it's only the GIF which has come to an end.)
**Desktop:**
- OS: Windows
- Browser Firefox/Chrome
- Version Firefox 130.0.1 / Chrome 129.0.6668.59 / Masonic 4.0.1
**Smartphone:**
(not tested)
**Additional context**
This doesn't happen with the basic `Masonry` component, only with `MasonryScroll`.
AFAICT the initial measurement doesn't take into account the height of the broken image placeholder inserted by the browser. When the browser gets around to inserting the placeholder, that triggers a React re-render; in which the measurement again doesn't include the height of the placeholder.
Setting `alt` to an empty or short string stops the flickering, presumably because the browser doesn't render the placeholder ([other methods for doing the same thing might also work](https://stackoverflow.com/q/22051573/111794)):

If there are no broken images in the initial viewport, scrolling down until a broken image comes into view triggers the flicker.
Moving to a different browser tab or a different window and then back, stops the flicker.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided CodeSandbox reproduction and inspect the MasonryScroller implementation, especially its initial measurement and re-render behavior when an image is broken. Compare it with the basic Masonry component and verify the fix by loading broken images both in the initial viewport and while scrolling; done means the column no longer flickers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100