From 9ca11fe5eb16675eeffbbbbafddc560297263022 Mon Sep 17 00:00:00 2001 From: Tobias Linsefors Date: Wed, 29 Mar 2023 14:50:13 +0200 Subject: [PATCH] fix: confirm selection when object is removed (#1197) --- apis/nucleus/src/hooks/useObjectSelections.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apis/nucleus/src/hooks/useObjectSelections.js b/apis/nucleus/src/hooks/useObjectSelections.js index d47f1a607..01a31b8a5 100644 --- a/apis/nucleus/src/hooks/useObjectSelections.js +++ b/apis/nucleus/src/hooks/useObjectSelections.js @@ -232,6 +232,12 @@ export default function useObjectSelections(app, model, elements, options) { objectSelections.addListener('deactivated', deactivateClickOut); return () => { + // confirm selection before removing event handler + // to end the selection when the object is removed + // and remove the (ClickOut) mousedown handler from the document + if (objectSelections.isActive()) { + objectSelections.confirm(); + } objectSelections.removeListener('activated', activateClickOut); objectSelections.removeListener('deactivated', deactivateClickOut); };