fix: fix blocks flashing on mount at zero-zero position#268
fix: fix blocks flashing on mount at zero-zero position#268draedful merged 3 commits intogravity-ui:mainfrom
Conversation
|
Preview is ready. |
draedful
left a comment
There was a problem hiding this comment.
Thanks for taking the time to contribute and for the clear write-up — fixes like this really help the library, and we appreciate you digging into the flashing issue.
The approach with useLayoutEffect looks good. One small follow-up: the new effect duplicates the geometry / z-index logic that already lives in useSignalEffect. Would you mind extracting a shared helper (e.g. something like applyBlockContainerLayout(...)) and calling it from both places? That way we keep mount-time and signal-driven updates aligned if this block changes later
|
@draedful extracted the common logic and moved it to a separate utils file |
draedful
left a comment
There was a problem hiding this comment.
Everything is fine, thanks for the contribution.
Problem
When blocks mount at the detailed react view, they flash at 0 0 position before rendering at the correct one.
How to reproduce
Why it happens
In
Block.tsxuseSignalEffect is only called after first render because it is run asynchronously. Hence, for a moment you can see blocks at the default positions at 0 0.Solution
Create another hook that sets the correct block positions that is run before the first render.
Bug screencast: https://github.com/user-attachments/assets/460df84c-e16a-4d00-812c-0cf40a9cc48c