Skip to content

fix(studio): a sealed Layers pick of a cropped layer puts its resize corners on the whole layer - #8468

Merged
miguel-heygen merged 2 commits into
mainfrom
dstoryboard/sealed-scaled-pick
Nov 22, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
dstoryboard/sealed-scaled-pick

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

What

In a sealed preview (Studio cannot script the frame), picking a cropped layer in the Layers panel now puts its resize corners on the whole layer, as an unsealed preview does. Before, the corners and the selection outline stayed pulled in to the crop, and on a scaled layer they landed short of even that, until something else made the overlay redraw.

Why

While a cropped layer is selected, Studio lifts its crop so the whole layer shows and the cut-away part can be dimmed. Until the lift, the selection box hugs the crop. The overlay read "is it lifted" from a plain map during render. The lift is made a moment later, by the crop handles. The overlay did render again after that, but nothing React tracks had changed (the measured box was the same), so React skipped committing that render and the box kept its pre-lift hug.

An unsealed preview hid this: its lift changes the element itself, so the overlay's next measure set new state and the box redrew. A sealed frame's measure comes back the same, so the hug stayed for good: at the pick, 2 s later, and after a mouse move.

Related work

Refs #8451 (the same layer's crop insets at its own scale in a sealed preview). That PR changes DomEditCropHandles.tsx; this one does not touch it.

How

  • domEditOverlayCrop.ts: the crop lift becomes a small store. Every change to a lift goes through setLift (or marks it dropped), and each change notifies subscribers. subscribeCropLifts and cropLiftsVersion expose it.
  • useCropOverlay.ts: subscribes with useSyncExternalStore, so the overlay redraws when a lift starts, lands, is refused by the frame, or drops, in both kinds of preview.

Before

Sealed, main: a cropped layer scaled by GSAP, clicked at 1 s, Escape, seek to 3.5 s, picked in Layers. The corners sit on the crop, short of the layer.

before, sealed

After

Sealed, this change, same steps: the corners sit on the whole layer. Then unsealed, for reference.

after, sealed unsealed

The dashed crop line and the side handles still differ from unsealed in the sealed capture: that is the inset scale #8451 fixes.

Test plan

  • fails without the fix: useCropOverlay.test.ts ("a sealed layer picked with no press drops its crop hug once the crop handles lift it, and gets it back when the frame refuses" and "an unsealed layer's crop hug follows its lift and its drop"). On main both fail with expected 150 to be null: the hug stays after the lift.
  • Real Studio on a Linux machine, sealed and unsealed, with the walk above: before, sealed corners span 37 px against 63 unsealed, with the crop hug on. After, both span 63 with no hug, at the pick, 2 s later and after a mouse move. The selection box is 62 px wide in every run.
  • With the fix, these pass: useCropOverlay.test.ts, domEditOverlayCrop.test.ts, domEditOverlayCropLift.test.ts, domEditOverlayCropFrameLift.test.ts, DomEditCropHandles.test.tsx, DomEditCropHandles.sealed.test.ts and DomEditOverlay.test.ts (83 tests), and studio's tsc --noEmit.

Not exercised: macOS and Safari (Chrome on Linux only); a rotated cropped layer picked in Layers.

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 71 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

@vanceingalls vanceingalls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved at 6210351, CI green. The crop lift was a plain map read during render, so in a sealed preview, where the frame's measure comes back the same, React skipped the commit and the selection box kept hugging the crop. Now every change to a lift goes through setLift and bumps a version. useCropOverlay subscribes with useSyncExternalStore (subscribeCropLifts and cropLiftsVersion), so the box redraws when a lift starts, lands, is refused or drops, in both kinds of preview. The sealed test checks the hug goes away on lift and comes back on a refusal, and fails without the fix. The unsealed case is pinned too. It doesn't touch DomEditCropHandles.tsx, so it won't collide with #8451.

Nit: dropElementCropLift calls setLift(element, null), which already notifies, and then liftsChanged() again, so subscribers render twice on a drop. It's harmless, but it can lose one call.

@vanceingalls vanceingalls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-approved at 5600a71. Since 6210351 the only change is 5600a719, which shortens one test comment to fit the line limit. No code changed.

Correction to my earlier nit: dropElementCropLift notifies once on each path. The lift.rule branch calls setLift(element, null) and returns, and only the frame-unlift branch calls liftsChanged(). I misread the diff fragments. Nothing to change there.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit f57552d Nov 22, 2026
78 checks passed
@miguel-heygen
miguel-heygen deleted the dstoryboard/sealed-scaled-pick branch November 22, 2026 10:36
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