fix(studio): a click after an empty-canvas press selects on the first try - #4759
Draft
miguel-heygen wants to merge 1 commit into
Draft
miguel-heygen wants to merge 1 commit into
miguel-heygen wants to merge 1 commit into
Conversation
This branch has not been deployed
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 the Studio preview, a click on an element right after a press on empty canvas now selects it on the first try. Before, that click selected nothing and only a second click worked. The same happened after a confident shift+click add.
Why
A press on empty canvas (which starts a marquee) and a confident shift+click both handle the press on
pointerdown, callpreventDefault(), and setsuppressNextOverlayMouseDownRefso that the same press'smousedownis not handled a second time. But a browser sends no compatibilitymousedownafter a default-preventedpointerdown. Nothing clears the flag, so the check inhandleOverlayMouseDownswallows the next real press instead (mousedown-suppressedin thehf-select-debuglog).Repro on main: turn on
localStorage["hf-select-debug"]="1", click empty canvas, then click an element once. Nothing is selected, and the log showsmousedown-suppressed.Related work
Refs #4747 (shift+drag axis lock and tap rollback) and #4754 (shift+click group removal). This PR does not change their behaviour.
How
The overlay's
onPointerDownCapturealready clearedsuppressNextBoxClickRefat the start of every press. It now clears all three suppress flags there (suppressNextOverlayMouseDownRef,suppressNextBoxMouseDownRef,suppressNextBoxClickRef). So there is one rule: a press's suppressions die when the next press begins. Every place that sets a flag runs after that capture within the same press (pointerdown, drag end, overlay mousedown), so it still guards its own press. Host mode (canvasInput: "host") never sets these two flags, so its behaviour is unchanged.Test plan
clickAfterPreventedPress.test.tsxfires a press the way Chrome does (nomousedownafter a preventedpointerdown). It covers an empty-canvas press and a shift+click add, each followed by a plain click. Both cases fail on main (expected "vi.fn()" to be called 1 times, but got 0 times) and pass with the fix. The neighbouring overlay suites (read-only overlay, shift-drag axis lock, group drop, marquee, selection chrome, inline text) pass: 118 tests.mousedown-suppressedcount across the walk: 4 before, 0 after.Before
Empty canvas, then one click on the red box: the box is hovered but nothing is selected.
Empty canvas, then a double-click on the headline: the editor opens, but nothing is selected.
After
The same click selects the red box on the first try.
The same double-click selects the headline and edits it.