Repository navigation
fix(studio): the selection handles move with the box and the layer while dragging - #8909
miguel-heygen wants to merge 3 commits into
Conversation
…ile dragging The resize handles were placed only by React's commit after each move, a frame after the box border and the element itself, so on screen the outline's corners trailed the dragged layer. They now sit in a wrapper placed like the box, and the move writes that wrapper in the same task as the box.
|
A rightward drag on a sealed preview (stock Chrome, the sandboxed frame in its own process), 6 px steps, the same displayed frame mid-drag in both runs, enlarged 3x from a 60 fps screen capture. BeforeOn AfterOn |
…test's options current drawOutline's name says what its two comment lines did. The raw pointer drag test from main builds the gesture options by hand and now passes the handles' ref too.
|
Rerun of the board's shared-process rows on
With #8899 the sealed layer no longer comes a step late in this mode, so the handles no longer lead it: the "leads by one step" note in the description no longer applies on this head. |
Edit accuracy: accurate 273 (base branch 271), smooth 63 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |


What
While you drag a selected layer on the canvas, the selection outline's four resize handles now stay on the layer's corners. Before, they trailed the layer by one frame, and by two on a sealed preview in stock Chrome.
Why
On every pointer move Studio writes the selection box's position straight away, in the move's own task, and the layer moves in that same frame. The resize handles did not take part in that write: their position came only from React's
overlayRectstate, which commits in a later task, after the frame has already been painted.Measured on
mainwith stock Chrome, real Studio and OS-level pointer input (XTest), 6 px steps:Neither mode reads the frame's geometry during a held drag: the per-frame re-measure is paused while a gesture is held, and the drag draws from its own draft.
How
DomEditSelectionChrome.tsx: the handles move into a wrapper (DomEditResizeHandles) placed exactly like the box. Each handle is pinned to the wrapper edges of its own corner (left/right,top/bottom), so resizing the wrapper carries the right and bottom handles with it. They stay siblings of the box, so the box's clip path still cannot cut them.drawOutline(domEditOverlayGestures.ts) writes the box and the handles' wrapper together.useDomEditOverlayGestures.tsuses it everywhere it wrote the box before: drag and resize moves, and the tap and release paths. React's later commit writes the same values.flushSyncon a move: forcing React's render into every move would add work to each move under CPU throttling.Not covered here:
Test plan
fails without the fix:
packages/studio/src/components/editor/selectionHandlesRideTheBox.test.ts"a drag move places the resize handles in the same write as the box" and "a resize move sizes the resize handles in the same write as the box" fail onmain(expected [ '', '', '', '' ] to deeply equal [ '50px', '42px', '', '' ]), and again with the handles' wrapper taken out of the move's write.src/components/editor/: 2215 passed, 0 failed. The two new tests andDomEditSelectionChrome.test.tsxpassed three runs in a row.tsc --noEmitinpackages/studiois clean.DomEditSelectionChromecomplexity is down from 20 cyclomatic / 23 cognitive to 17 / 23.Screen board on the devbox: stock Chrome, built CLI, the edit-accuracy resize fixture, drags of 40 × 6 px steps, sealed and unsealed sessions interleaved, the preview frame's
originchecked each session (nullsealed). Below, how many steps the layer and the outline's handles trail the drawn pointer: the most common value over about 39 moving frames per session, 3 sessions per row.--disable-features=IsolateSandboxedIframes)With the sealed frame sharing Studio's process, the handles now lead the layer by one step. The handles are on time there; it is the layer that is late, because a sealed frame in Studio's process applies the drag one frame after Studio paints. That belongs to the separate work on the sealed drag's layer step (the WebKit-class hop), not to the outline. On
mainthe handles' own lag hid it.Not run: CPU throttling, other browsers.
Before and After captures follow in a comment.