From 994b0f8baae86a2251bd502e21d1e7311b8700c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mime=20=C4=8Cuvalo?= Date: Tue, 9 Apr 2024 08:49:24 +0100 Subject: [PATCH] textfields: only do pointer capture when not editing (#3407) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://linear.app/tldraw/issue/TLD-2374/can-lose-focus-and-caret #focus-issues #blood-moat ### Change Type - [x] `sdk` — Changes the tldraw SDK - [ ] `dotcom` — Changes the tldraw.com web app - [ ] `docs` — Changes to the documentation, examples, or templates. - [ ] `vs code` — Changes to the vscode plugin - [ ] `internal` — Does not affect user-facing stuff - [x] `bugfix` — Bug fix - [ ] `feature` — New feature - [ ] `improvement` — Improving existing features - [ ] `chore` — Updating dependencies, other boring stuff - [ ] `galaxy brain` — Architectural changes - [ ] `tests` — Changes to any test code - [ ] `tools` — Changes to infrastructure, CI, internal scripts, debugging tools, etc. - [ ] `dunno` — I don't know --- packages/tldraw/src/lib/shapes/shared/useEditableText.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/tldraw/src/lib/shapes/shared/useEditableText.ts b/packages/tldraw/src/lib/shapes/shared/useEditableText.ts index cafb378c9..59aebf34e 100644 --- a/packages/tldraw/src/lib/shapes/shared/useEditableText.ts +++ b/packages/tldraw/src/lib/shapes/shared/useEditableText.ts @@ -160,9 +160,11 @@ export function useEditableText(id: TLShapeId, type: string, text: string) { // This is important so that when dragging a shape using the text label, // the shape continues to be dragged, even if the cursor is over the UI. - setPointerCapture(e.currentTarget, e) + if (!isEditing) { + setPointerCapture(e.currentTarget, e) + } }, - [editor, id] + [editor, id, isEditing] ) const handleDoubleClick = stopEventPropagation