Repository navigation
fix(studio): a press just after a sealed preview reloads drags the selection - #9126
Conversation
…lection After a reload, a sealed frame no longer knows the selection's handle from the page before, so the box was dropped until Studio found the selection again on the new page. A press in that time landed on nothing and started no drag. The box now stays where it was shown until then, and a press on it waits and starts on the new page, as a press during the reload does.
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at dace79b. No blocker.
Read: useDomEditOverlayRects.ts whole at head; the test file as its hunk; currentLoadHandle in previewSelection.ts and the selection refresh in useDomSelection.ts (lines 365 to 425) to see when a kept box goes away.
Checked
fails without the fix:line is present and names the new test. By reading: on main the channel answerelements: [null]goes straight tosetOverlayRect(null), soshownLeft()cannot stay 230 there.- The box is kept only when the frame measured none AND the selection's handle is not one the current page knows. A selection the current page knows and does not show still gets
null, so hidden elements lose the box as before. The scriptable-frame path (update) is untouched. - A kept box does not outlive a removed element: the refresh clears the selection when the element is not found on the new page, and with no selection the channel path clears every box.
- Group members use the same rule keyed by the member's cache key; the body says this path has no test.
Note, not blocking
- If the refresh gets no answer from the frame (
findSelectionElementreturns undefined), the selection keeps its old handle and the box now stays at its last place until the next refresh or reload. Before, it vanished. A press there still waits and looks the selection up again, so I read this as acceptable; say if you want a bound on it.
Not run: the test file and type check (no installed packages on this machine). No check was red when I posted; several were still pending.
Need: yes · Size: small · Reuse: uses the existing page-handle lookup · Simpler: no · Structure: fine
Risk: low to medium; sealed preview only, which is not the default.
— Rames
Edit accuracy: accurate 275 (base branch 273), smooth 60 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
A press on the selected element right after a sealed preview reloads now drags it, as it does unsealed. After a reload the new page's frame does not know the selection's handle from the page before. So Studio dropped the selection box until it had found the selection again on the new page, which takes a round trip to the frame. A press in that time landed on the empty canvas and started nothing: no drag, no save. The box now stays where it was shown until the selection is found again. A press on it waits and starts on the new page, as a press during the reload itself already did.
seqplainkeys-none-px-r30-nested-z100, 4 times in 28 replays).seqplainkeys-none-px-r0-root-z100andseqplainkeys-none-pct-r0-root-z100failed in the merge queue with the same error, dropping pull requests that changed sealed preview paths.Why
The sealed preview may only become the default once it behaves as the unsealed one does. Unsealed, the overlay finds the selected element in the live page every frame, so there is no such gap.
Related work
Follow-up to #9068 and #9089 (the sealed edit accuracy run and its gate). #9107 and #9121 fix the other two sealed-only failures in the same run.
How
useDomEditOverlayRects.ts: when the frame measures no box for the selection, or for a member of a group selection, and that selection's handle is from the page before the current one (currentLoadHandleno longer names it), the box keeps the place it was last shown. A selection the current page does not show, or one whose element is gone, still loses its box as before.previewGestureStarts.ts); it only needed a box to press.Test plan
fails without the fix: "keeps the box while a reloaded page's selection is found again, and a press on it starts on the new page" (
packages/studio/src/components/editor/gestureStartReadAhead.sealed.test.ts) swaps in a new page whose frame answers the old handle with nothing. Without the fix the box is dropped on that answer. The press on the kept box starts a drag once the selection is found on the new page.Not tested: the group selection path. It uses the same check, and only the type check runs over it.
The 21 Studio test files that use the overlay rects, the overlay's frame reads,
currentLoadHandle,DomEditOverlayor the read made before a press: 288 of 288, 3 runs in a row.tsc --noEmitinpackages/studio: exit 0.Edit accuracy bench, sealed build, the 25 cases of the merge queue's shard 3 with a log of each press. Before: "save never landed" in 4 of 28 replays, In the 21 of those replays that logged each press, 4 presses landed while the selection was being found again: 3 hit a box still drawn and saved, and the one that met no box was a failure. After: 0 of 12 replays, and the one press made during a re-find hit the kept box and saved. One replay after the fix lost a crop on release (
crop-keys-px-r0-root-z50-after). The merge queue's runs show the same 40 px crop loss on two other sealed crop cases without this change, so that is a separate failure.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
No visible change
The sealed preview is not on by default. In a sealed preview, the selection box no longer disappears for a moment after an edit reloads the preview.