Skip to content

fix(web): keep the grid preview pinned to the section it is previewing - #144

Open
TheMaestr-o wants to merge 1 commit into
feat/home-grid-polishfrom
fix/grid-preview-scroll
Open

fix(web): keep the grid preview pinned to the section it is previewing#144
TheMaestr-o wants to merge 1 commit into
feat/home-grid-polishfrom
fix/grid-preview-scroll

Conversation

@TheMaestr-o

Copy link
Copy Markdown
Collaborator

What does this PR do?

Keeps the admin's grid preview pinned to the section it is previewing, instead of drifting back to the hero.


Base: feat/home-grid-polish (#136) — merge that first. No issue of its own.

The preview scrolled itself to the grid with a single setTimeout(120), which raced the page it was measuring. At 120ms the globe, the fonts and the card photos are still landing, so the offset it computed was stale a moment later and the frame settled back on the hero — intermittently, and more often on a slow machine, which is exactly what made it look like it worked.

It also never ran again. Switching the editor between desktop, tablet and mobile reflows the document to a different height, but the scroll position stayed where the old layout had put it, so the two panes could disagree about what they were showing.

Fix

The section is pinned on mount and re-pinned on load, on resize, and whenever a ResizeObserver sees the document or the section change size — all coalesced through one animation frame.

Verification

  • 15 runs at normal, 4× and 8× CPU throttling: identical every time, both panes in sync, 97% of the section in frame.
  • Desktop → tablet → mobile → desktop re-pins each time (scrollY 558 → 732 → 549 → 558) with section top = 0 in every mode. Before the fix scrollY stayed at 558 throughout.

@TheMaestr-o TheMaestr-o self-assigned this Aug 3, 2026
@TheMaestr-o
TheMaestr-o force-pushed the feat/home-grid-polish branch from a299e60 to 2154f2d Compare August 3, 2026 06:03
@TheMaestr-o
TheMaestr-o force-pushed the fix/grid-preview-scroll branch from 53ce4f3 to 493e7da Compare August 3, 2026 06:04
@TheMaestr-o
TheMaestr-o force-pushed the feat/home-grid-polish branch from 2154f2d to e25ccdd Compare August 3, 2026 06:12
The preview scrolled itself to the grid with a single setTimeout(120), which
raced the page it was measuring. At 120ms the globe, the fonts and the card
photos are still landing, so the offset it computed was stale a moment later
and the frame settled back on the hero — intermittently, and more often on a
slow machine, which is what made it look like it worked.

It also never ran again. Switching the editor between desktop, tablet and
mobile reflows the document to a different height, but the scroll position
stayed where the old layout had put it, so the two panes could disagree about
what they were showing.

The section is pinned on mount and re-pinned on load, on resize and whenever a
ResizeObserver sees the document or the section change size, coalesced through
one animation frame.

Verified 15 runs at normal, 4x and 8x CPU throttling: identical every time,
both panes in sync, 97% of the section in frame. Switching desktop -> tablet ->
mobile -> desktop re-pins each time (scrollY 558 -> 732 -> 549 -> 558) with the
section at the top of the frame in every mode; before, scrollY stayed at 558
throughout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant