From 52e9a078c9900a04e34ba3ccc382d2dc6929f265 Mon Sep 17 00:00:00 2001 From: Igor Zinken Date: Wed, 20 Jan 2021 09:59:51 +0100 Subject: [PATCH] When switching active tool after drawing an unclosed selection, the selection should be reset --- src/components/document-canvas/document-canvas.vue | 2 +- src/rendering/canvas-elements/interaction-pane.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/document-canvas/document-canvas.vue b/src/components/document-canvas/document-canvas.vue index abd36df..00aac15 100644 --- a/src/components/document-canvas/document-canvas.vue +++ b/src/components/document-canvas/document-canvas.vue @@ -201,7 +201,7 @@ export default { this.updateInteractionPane(); } else { this.handleCursor(); - getCanvasInstance()?.interactionPane.setInteractive( false ); + getCanvasInstance()?.interactionPane?.handleActiveTool( tool, false ); } }, zoomOptions: { diff --git a/src/rendering/canvas-elements/interaction-pane.js b/src/rendering/canvas-elements/interaction-pane.js index 3437242..415a065 100644 --- a/src/rendering/canvas-elements/interaction-pane.js +++ b/src/rendering/canvas-elements/interaction-pane.js @@ -94,6 +94,14 @@ class InteractionPane extends sprite { } } + handleActiveTool( tool, remainInteractive ) { + if ( tool !== ToolTypes.LASSO && this.document?.selection && !this._selectionClosed ) { + // reset unclosed selection when switching tools + this.resetSelection(); + } + this.setInteractive( remainInteractive ); + } + stayOnTop() { if ( !this._enabled ) { return;