You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(comment): keep pins glued to their element across iframe scroll
Root cause: overlay.ts captured getBoundingClientRect() once at click time
and sent viewport-relative coords to the parent. The PinOverlay sits outside
the iframe and has no way to observe iframe-internal scroll, so the pin
stayed at the old viewport coordinates while the selected element moved
with the scrolled content.
Fix: iframe becomes the source of truth for rect.
- New WATCH_SELECTORS message (parent→iframe) registers the selectors
the parent cares about for the current design/snapshot.
- New ELEMENT_RECTS message (iframe→parent) broadcasts current rects
on scroll/resize, rAF-coalesced so bursts collapse into one post.
- Parent stores a liveRects map keyed by selector; PinOverlay and the
CommentBubble prefer it over the stored rect when present.
- Freshly-pinned elements auto-add themselves to the iframe's watch
list so scroll tracking works before the parent round-trip lands.
DB schema untouched — stored rect is still the initial value before the
iframe broadcasts its first update. liveRects is cleared on design switch.
Test coverage: overlay rAF coalescing, scroll re-broadcast, selector
resolution fallbacks, ELEMENT_RECTS handler validation, store merge/clear
semantics, PinOverlay rendering with live rect override.
// Tell the sandbox which selectors to track. The sandbox re-measures each
324
+
// on scroll/resize and broadcasts ELEMENT_RECTS; we merge into liveRects.
325
+
// Selectors: all comments on the current snapshot + the active bubble's
326
+
// selector (usually the freshly-pinned one, included for the moment
327
+
// between click and save).
328
+
// biome-ignore lint/correctness/useExhaustiveDependencies: currentDesignId is intentional — iframeRef.current is a ref so biome can't see that it changes with the active design. When the design switches we MUST resend WATCH_SELECTORS to the newly-active iframe; the currentDesignId dependency is what triggers that re-run.
0 commit comments