Skip to content

fix(studio): show inspector selection bounds after click reliably#789

Merged
miguel-heygen merged 1 commit into
heygen-com:mainfrom
func25:fix/pause-select
May 13, 2026
Merged

fix(studio): show inspector selection bounds after click reliably#789
miguel-heygen merged 1 commit into
heygen-com:mainfrom
func25:fix/pause-select

Conversation

@func25
Copy link
Copy Markdown
Contributor

@func25 func25 commented May 13, 2026

What

Fix Studio inspector bounds not showing right after click.

Why

Click could select the element, but the bounds still did not show.

This happened because the bounds ref was updated first. Then the React state update looked like "nothing changed", so the UI did not re-render.

How

Keep bounds updates going through the overlay setters.

Do not write to the bounds ref before calling the setter.
This keeps the ref and React state in sync, so the selected bounds render right after click.

Test plan

How was this tested?

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)

Copy link
Copy Markdown
Collaborator

@miguel-heygen miguel-heygen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix for a subtle React rendering bug.

Root cause analysis: The click handler wrote overlayRectRef.current = candidateRect before calling setOverlayRect(candidateRect). Since setOverlayRect deduplicates via rectsEqual(overlayRectRef.current, next), the early ref write made the setter think nothing changed — setOverlayRectState was never called, no re-render happened, and the selection bounds didn't appear.

Fix is correct: removing the premature ref write in DomEditOverlay.tsx:226 lets setOverlayRect (inside useDomEditOverlayRects) be the single authority on both the ref and the React state — they stay in sync.

Gesture handler cleanup is also right: setDraftOverlayRect and setDraftGroupOverlayItems in the gesture handlers were doing redundant ref-then-equality checks that duplicate what useDomEditOverlayRects.setOverlayRect already does. Removing them simplifies the flow and prevents the same premature-ref-write pattern from causing issues during drag operations.

Test: the harness correctly mocks the overlay geometry to return a deterministic rect, renders a DomEditOverlay, dispatches a pointerdown, and asserts the selection box appears. The mock for useDomEditOverlayRects faithfully replicates the deduplication logic from the real hook.

Looks good to merge.

@miguel-heygen miguel-heygen merged commit 10fb968 into heygen-com:main May 13, 2026
22 of 24 checks passed
@func25 func25 deleted the fix/pause-select branch May 13, 2026 07:27
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.

2 participants