Skip to content

Commit

Permalink
Merge branch 'recogito#133-fix-not-dismissed-annotation-on-outside-cl…
Browse files Browse the repository at this point in the history
…ick' into staging

# Conflicts:
#	packages/text-annotator/src/SelectionHandler.ts
  • Loading branch information
oleksandr-danylchenko committed Aug 13, 2024
2 parents 59e8437 + e492c82 commit 3731741
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/text-annotator/src/SelectionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const createSelectionHandler = (
lastDownEvent = clonePointerEvent(evt);
isLeftClick = lastDownEvent.button === 0;
}
container.addEventListener('pointerdown', onPointerDown);
document.addEventListener('pointerdown', onPointerDown);

const onPointerUp = (evt: PointerEvent) => {
const annotatable = !(evt.target as Node).parentElement?.closest(NOT_ANNOTATABLE_SELECTOR);
Expand All @@ -152,7 +152,11 @@ export const createSelectionHandler = (
const userSelect = () => {
const { x, y } = container.getBoundingClientRect();

const hovered = store.getAt(evt.clientX - x, evt.clientY - y, currentFilter);
const hovered =
evt.target instanceof Node &&
container.contains(evt.target) &&
store.getAt(evt.clientX - x, evt.clientY - y, currentFilter);

if (hovered) {
const { selected } = selection;

Expand Down Expand Up @@ -219,7 +223,7 @@ export const createSelectionHandler = (
container.removeEventListener('selectstart', onSelectStart);
document.removeEventListener('selectionchange', onSelectionChange);

container.removeEventListener('pointerdown', onPointerDown);
document.removeEventListener('pointerdown', onPointerDown);
document.removeEventListener('pointerup', onPointerUp);

hotkeys.unbind();
Expand Down

0 comments on commit 3731741

Please sign in to comment.