Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions packages/text-annotator/src/SelectionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ export const SelectionHandler = (

let lastDownEvent: Selection['event'] | undefined;

let isContextMenuOpen = false;

const onSelectStart = (evt: Event) => {
isContextMenuOpen = false;

if (isLeftClick === false)
return;

Expand Down Expand Up @@ -161,8 +157,6 @@ export const SelectionHandler = (
* to the initial pointerdown event and remember the button
*/
const onPointerDown = (evt: PointerEvent) => {
if (isContextMenuOpen) return;

if (isNotAnnotatable(evt.target as Node)) return;

/**
Expand All @@ -188,8 +182,6 @@ export const SelectionHandler = (
}

const onPointerUp = (evt: PointerEvent) => {
if (isContextMenuOpen) return;

if (isNotAnnotatable(evt.target as Node) || !isLeftClick) return;

// Logic for selecting an existing annotation
Expand Down Expand Up @@ -239,8 +231,6 @@ export const SelectionHandler = (
}

const onContextMenu = (evt: PointerEvent) => {
isContextMenuOpen = true;

const sel = document.getSelection();

if (sel?.isCollapsed) return;
Expand Down Expand Up @@ -282,15 +272,15 @@ export const SelectionHandler = (

selection.userSelect(currentTarget.annotation, cloneKeyboardEvent(evt));
}

document.removeEventListener('selectionchange', onSelected);

// Sigh... this needs a delay to work. But doesn't seem reliable.
}, 100);

// Listen to the change event that follows
document.addEventListener('selectionchange', onSelected);

// Start selection!
onSelectStart(evt);
}
Expand Down