From 23f762a5a473e9c4328a7c373619baef0e698af4 Mon Sep 17 00:00:00 2001 From: Oleksandr Danylchenko Date: Thu, 10 Oct 2024 18:24:35 +0300 Subject: [PATCH 1/2] Restored selection cleanup on selection change --- packages/text-annotator/src/SelectionHandler.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/text-annotator/src/SelectionHandler.ts b/packages/text-annotator/src/SelectionHandler.ts index 801e0f1c..3c8fb064 100644 --- a/packages/text-annotator/src/SelectionHandler.ts +++ b/packages/text-annotator/src/SelectionHandler.ts @@ -149,6 +149,9 @@ export const SelectionHandler = ( */ if (store.getAnnotation(currentTarget.annotation)) { store.updateTarget(currentTarget, Origin.LOCAL); + } else { + // Proper lifecycle management: clear the previous selection first... + selection.clear(); } }); From d1dddc99b62c6f14e135f86630918771c00fb331 Mon Sep 17 00:00:00 2001 From: Oleksandr Danylchenko Date: Thu, 10 Oct 2024 18:25:11 +0300 Subject: [PATCH 2/2] Removed redundant cleaned selection check --- packages/text-annotator/src/SelectionHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/text-annotator/src/SelectionHandler.ts b/packages/text-annotator/src/SelectionHandler.ts index 3c8fb064..b61d6dc4 100644 --- a/packages/text-annotator/src/SelectionHandler.ts +++ b/packages/text-annotator/src/SelectionHandler.ts @@ -209,7 +209,7 @@ export const SelectionHandler = ( if (selected.length !== 1 || selected[0].id !== hovered.id) { selection.userSelect(hovered.id, evt); } - } else if (!selection.isEmpty()) { + } else { selection.clear(); } };