Repository navigation
fix(studio): a sealed resize keeps the dragged corner on the pointer at fractional sizes - #8560
Merged
Merged
Conversation
… an unsealed one measures
…at fractional sizes
Contributor
Edit accuracy: accurate 271 (base branch 271), smooth 69 of thoseThe gate passes. Quarantined, measured but not gated (0) |
jrusso1020
approved these changes
Nov 23, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed at ba78559c.
- The sealed draft now calls
resizeRemainderShiftwith corners built from the gesture's centre, rotation and edit scale, and the same grab point as the unsealed draft (grabOf, shared by both). The shift is in overlay px, the same units the existing(w/2)*editScaleXterm and the unsealed anchor target use. Only the sealed path passeswanted, so its one caller is the only change in behaviour. - Red first: with
resizeDraft.tsfrommain, "moves a sealed box by the same rounding remainder an unsealed draft measures" fails. It passes at head. resizeDraft,domEditResizeLocal,anchoredResizeReleaseShift,previewDraftsandDomEditOverlaytests pass locally. All CI is green.- Studio-only change with no CLI surface, so no docs are needed.
Nits (non-blocking):
- The
+ shift.x/+ shift.yon the returned overlay rect isn't pinned by a test. Dropping both keeps every test green. gestureCornersassumes a rotated, uniformly edit-scaled box. WhenresizeGrowcomes from a skewed or otherwise non-rotation transform, the sealed remainder direction can differ from what the unsealed draft measures. That is at most half the rounding remainder, so not a blocker; it's worth a case in the bench if skewed layers get sealed coverage.
Need ✅ · Size ✅ · Reuse ✅ (resizeRemainderShift stays the one owner) · Simpler ✅ · Structure ✅
Risk: low. Sealed previews are off by default, and the change is a sub-pixel draft shift.
— Rames (hf-review)
This was referenced Nov 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
In a sealed preview, the corner you drag in a resize now stays on the pointer. Before, it sat up to half a pixel short whenever the size the drag asked for wasn't a whole number, while an unsealed preview kept it exact. Sealed and unsealed now draw the same box.
Why
A resize writes whole-pixel sizes. To keep the dragged corner where the wanted, fractional size would put it, the unsealed draft moves the box by half the rounding remainder along its own edges (
resizeRemainderShift, which reads the element's corners from the frame). A sealed frame can't be measured, so its draft pinned the box on the written size alone and dropped that remainder.Related work
Follows the sealed resize centre fix (#8547): the same draft, the remainder it still left out.
How
packages/studio/src/components/editor/resizeDraft.ts:resizeRemainderShiftstays the one owner of the remainder. The sealed draft builds the box's corners at the written size from the gesture's own centre, rotation and edit scale, and calls it with the same grab point the unsealed draft uses. The pin and the box Studio draws over the frame both move by that shift.Test plan
fails without the fix:
packages/studio/src/components/editor/resizeDraft.test.ts, "moves a sealed box by the same rounding remainder an unsealed draft measures". On main the sealed pin is 0.37 px off the remainder the unsealed draft measures for a 300.6 x 150.3 px wanted size on a turned, scaled box; with the fix it is within 0.07 px.With the fix, on a Linux machine:
resizeDraft.test.ts,domEditResizeLocal.test.ts,anchoredResizeReleaseShift.test.ts,previewDrafts.test.tsandDomEditOverlay.test.tspass three runs in a row. The push gate's covering files, Studiotsc, Fallow and pre-push are clean.Bench
Edit-accuracy bench on a Linux machine, the 13 scale resize cases, main at da7faad with and without this change, the same bench for both, two runs per mode. Worst value across the 13 cases, in px (a case fails over 0.5):
The two
-z50-aftercases that failed on main at 0.52 to 0.53 now pass.Still different sealed, not changed by this PR:
-aftercases settle 0.47 to 0.48 px from the pointer after release sealed, against 0.05 unsealed.No visible change
Sealed previews are off by default, so nothing changes for anyone yet. With them on, a resized layer's corner stays under the pointer.