Fix text disappearing on canvas click-outside#1
Merged
dreamteam-mobile merged 6 commits intomainfrom Feb 19, 2026
Merged
Conversation
When a user typed text in the drawing pane's text input and clicked elsewhere on the canvas, the text was lost. The root cause: handleMouseDown changed the overlay key (via forceOverlayUpdate), unmounting the old TextInputOverlay before its blur handler could read the input value. Fix: - In handleMouseDown (text tool), read the DOM input value and commit it before creating a new overlay - Move handleTextCommit/handleTextDismiss before handleMouseDown to avoid temporal dead zone issues in the dependency array - Add committedRef guard in TextInputOverlay to prevent double-commit when Enter/Escape is followed by blur on unmount
…tool - Multi-line text: textarea replaces input, Enter=newline, Ctrl/Cmd+Enter=commit - Text positioning: overlay offset accounts for padding+border alignment - Click existing text to edit: findTextAtPosition hit-testing, in-place update - Double-click shapes: pre-fills overlay with existing shape text, uses shape center - Selection tool: select/move any element (pen, line, rect, circle, text) with visual dashed-border feedback and drag-to-move - WebRTC sync fix: strokeVersion counter in store triggers full sync on in-place updates (updateStrokeAt) that don't change array length - CLAUDE.md: add commit rules (no co-author lines) - 6 new test files (50+ tests), updated existing tests for Ctrl+Enter
Intercept Tab keydown in the code textarea, preventDefault to stop focus change, and insert 4 spaces at cursor position. Integrates with the existing OT pipeline so tab insertions sync to peers.
Shift+Tab removes up to 4 leading spaces from the current line or all selected lines. Only removes space characters, stops at non-space. Pure dedentLines() function extracted to code-editor-logic.ts for testability. 19 new tests (14 unit + 5 integration).
Rectangle: point-to-segment distance for all 4 edges + interior check Circle: distance from center vs radius (perimeter + interior) Line: point-to-segment distance along full length Text: bounding box with eraseRadius padding
Enter: new line starts at same indentation as current line. Tab/Shift+Tab: replaced requestAnimationFrame cursor positioning with useLayoutEffect + pendingCursorRef for reliable first-press behavior. Extracted shared applyEdit helper to reduce duplication.
160e36f to
bec06fe
Compare
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
handleMouseDownchanged the overlay React key, unmounting the oldTextInputOverlaybefore its blur handler could read the input valuecommittedRefguard inTextInputOverlayto prevent double-commit when Enter/Escape is followed by blur on unmountTest plan
canvasTextCommit.test.tsxverifies text persists in store when committed via Enter and via click-outside (blur)🤖 Generated with Claude Code