Skip to content

Commit 4c7c67e

Browse files
committed
Minor touch tweak
1 parent c8000a1 commit 4c7c67e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/text-annotator/src/SelectionHandler.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export const SelectionHandler = (
5050

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

53+
let isContextMenuOpen = false;
54+
5355
const onSelectStart = (evt: Event) => {
5456
if (isLeftClick === false)
5557
return;
@@ -152,6 +154,8 @@ export const SelectionHandler = (
152154
* to the initial pointerdown event and remember the button
153155
*/
154156
const onPointerDown = (evt: PointerEvent) => {
157+
if (isContextMenuOpen) return;
158+
155159
const annotatable = !(evt.target as Node).parentElement?.closest(NOT_ANNOTATABLE_SELECTOR);
156160
if (!annotatable) return;
157161

@@ -178,6 +182,8 @@ export const SelectionHandler = (
178182
}
179183

180184
const onPointerUp = (evt: PointerEvent) => {
185+
if (isContextMenuOpen) return;
186+
181187
const annotatable = !(evt.target as Node).parentElement?.closest(NOT_ANNOTATABLE_SELECTOR);
182188
if (!annotatable || !isLeftClick) return;
183189

@@ -227,6 +233,8 @@ export const SelectionHandler = (
227233
}
228234

229235
const onContextMenu = (evt: PointerEvent) => {
236+
isContextMenuOpen = true;
237+
230238
const sel = document.getSelection();
231239

232240
if (sel?.isCollapsed) return;

0 commit comments

Comments
 (0)