Skip to content

Commit 775f612

Browse files
authored
Merge pull request #155 from oleksandr-danylchenko/fix-previous-selection-cleanup
Added missing previous selection discard upon the new selection change
2 parents 9ce6e88 + d1dddc9 commit 775f612

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/text-annotator/src/SelectionHandler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ export const SelectionHandler = (
149149
*/
150150
if (store.getAnnotation(currentTarget.annotation)) {
151151
store.updateTarget(currentTarget, Origin.LOCAL);
152+
} else {
153+
// Proper lifecycle management: clear the previous selection first...
154+
selection.clear();
152155
}
153156
});
154157

@@ -206,7 +209,7 @@ export const SelectionHandler = (
206209
if (selected.length !== 1 || selected[0].id !== hovered.id) {
207210
selection.userSelect(hovered.id, evt);
208211
}
209-
} else if (!selection.isEmpty()) {
212+
} else {
210213
selection.clear();
211214
}
212215
};

0 commit comments

Comments
 (0)