From 757aa700a972acb48b6d47aa2ebb6e616a11101e Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Mon, 25 Nov 2024 15:11:25 -0500 Subject: [PATCH] EPUB/Snapshot: Fix selection with touch while tool is active --- src/dom/common/dom-view.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dom/common/dom-view.tsx b/src/dom/common/dom-view.tsx index bcda2ca0..37bb9109 100644 --- a/src/dom/common/dom-view.tsx +++ b/src/dom/common/dom-view.tsx @@ -1062,7 +1062,8 @@ abstract class DOMView { this._pointerMovedWhileDown = false; if ((event.pointerType === 'touch' || event.pointerType === 'pen') - && (this._tool.type === 'highlight' || this._tool.type === 'underline')) { + && (this._tool.type === 'highlight' || this._tool.type === 'underline') + && event.target !== this._annotationShadowRoot.host) { this._touchAnnotationStartPosition = caretPositionFromPoint(this._iframeDocument, event.clientX, event.clientY); this._iframeDocument.body.classList.add('creating-touch-annotation'); event.stopPropagation(); @@ -1088,7 +1089,7 @@ abstract class DOMView { return; } - if (!(event.target as Element).closest('#annotation-overlay')) { + if (event.target !== this._annotationShadowRoot.host) { // Deselect annotations when clicking outside the annotation layer if (this._selectedAnnotationIDs.length) { this._options.onSelectAnnotations([], event);