From dae32c7cd27fe5e25011a59bd323b66f3d1432cb Mon Sep 17 00:00:00 2001 From: Oleksandr Danylchenko Date: Wed, 28 Aug 2024 19:06:11 +0300 Subject: [PATCH] Added selection state cleanup on annotating disabling --- packages/text-annotator/src/SelectionHandler.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/text-annotator/src/SelectionHandler.ts b/packages/text-annotator/src/SelectionHandler.ts index 2027fc4d..905f2397 100644 --- a/packages/text-annotator/src/SelectionHandler.ts +++ b/packages/text-annotator/src/SelectionHandler.ts @@ -27,7 +27,16 @@ export const createSelectionHandler = ( let currentAnnotatingEnabled = true; - const setAnnotatingEnabled = (enabled: boolean) => currentAnnotatingEnabled = enabled; + const setAnnotatingEnabled = (enabled: boolean) => { + currentAnnotatingEnabled = enabled; + + if (!enabled) { + currentTarget = undefined; + lastPointerDown = undefined; + + onSelectionChange.clear(); + } + }; const { store, selection } = state;