From 852187058a000a0527b5fe270cf783b9c84355b0 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Mon, 2 Oct 2023 10:46:59 +0100 Subject: [PATCH] [fix] Drawing tool touch for first pen mark (#1977) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes a bug where a touch from a palm received at the start of a drawing operation, when that operation was the first entry into pen mode, would cause the line to fail. ### Change Type - [x] `patch` — Bug fix ### Test Plan 1. On an iPad with a pencil, select the draw tool. Ensure that you're not yet in pen mode. 2. Place your palm on the iPad and immediately place the pencil on the screen. 3. Previously, you would get a line between your palm and the pencil point. Now, you should get only the pencil point. ### Release Notes - [fix] Accidental palm inputs when using iPad pencil --- .../src/lib/shapes/draw/toolStates/Drawing.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/tldraw/src/lib/shapes/draw/toolStates/Drawing.ts b/packages/tldraw/src/lib/shapes/draw/toolStates/Drawing.ts index 07ae09b29..b6d91a76c 100644 --- a/packages/tldraw/src/lib/shapes/draw/toolStates/Drawing.ts +++ b/packages/tldraw/src/lib/shapes/draw/toolStates/Drawing.ts @@ -69,13 +69,17 @@ export class Drawing extends StateNode { // The user made a palm gesture before starting a pen gesture; // ideally we'd start the new shape here but we could also just bail // as the next interaction will work correctly - this.cancel() - } - - // If we came in from a menu but have no started dragging... - if (!this.canDraw && inputs.isDragging) { - this.startShape() - this.canDraw = true // bad name + if (this.markId) { + this.editor.bailToMark(this.markId) + this.startShape() + return + } + } else { + // If we came in from a menu but have no started dragging... + if (!this.canDraw && inputs.isDragging) { + this.startShape() + this.canDraw = true // bad name + } } if (this.canDraw) {