fix(board): stop phantom text node when dbl-clicking custom node title#146
Merged
Conversation
Dbl-clicking a custom node's title (sheet, code-sandbox, widget, etc.) spawned a stray text note on the canvas. The title sits OUTSIDE the node's canvas-harness hit-test rect (positioned absolute below the body), so canvas-harness's native dblclick listener saw the click as empty-space and fell through harness-canvas's "create text node" branch. Stop the native dblclick at the title's wrapper div so it never reaches canvas-harness. The wrapper is chosen specifically because it's the only parent that stays mounted across edit-mode transitions — `useEffect` deps don't track `ref.current` mutations, so binding to the button or input (which swap on `editing`) would only catch one of them. A new `useStopCanvasDblClick` hook holds the native stop, mirrored from the existing `useStopCanvasGesture` (pointerdown). It's a separate hook on purpose: blanket-stopping dblclick on a body ref would also block React's synthetic onDoubleClick on the same element (React 17+ root delegation), which would break sheet's inline editor entry. The new hook is only safe on subtrees with no meaningful React onDoubleClick — the docstring spells this out.
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.
Summary
Dbl-clicking a custom node's title (sheet, code-sandbox, widget, mini-app, folder, document, icon, image) spawned a stray text note on the canvas. The title is positioned absolute below the node — outside canvas-harness's hit-test rect — so the native dblclick saw it as empty space and fell through harness-canvas's "create text node" branch.
What's in the diff
Why `useStopCanvasDblClick` is a SEPARATE hook
React 17+ delegates events at the root container. A native `stopPropagation` below the root also blocks React's synthetic `onDoubleClick` on any descendant. The sheet body relies on its React `onDoubleClick` to open the inline editor (sheet/view.tsx:155) — so we can't blanket-stop dblclick everywhere.
The split lets each callsite pick its level of stopping:
The new hook's docstring spells out when it's safe to use.
Why the wrapper, not the button/input
`editing` flips between `` and ``. The buttonRef is set on first render; the inputRef is null at first render (since the input isn't mounted yet), and `useEffect` deps `[ref]` don't re-trigger when the input later mounts. So the input never got a listener — and the user's double-click resolves on the input by the time the second click lands. The wrapper `
Test plan