Skip to content

Commit

Permalink
EPUB/Snapshot: Fix selection with touch while tool is active
Browse files Browse the repository at this point in the history
  • Loading branch information
AbeJellinek committed Nov 25, 2024
1 parent ca0a460 commit 757aa70
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dom/common/dom-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,8 @@ abstract class DOMView<State extends DOMViewState, Data> {
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();
Expand All @@ -1088,7 +1089,7 @@ abstract class DOMView<State extends DOMViewState, Data> {
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);
Expand Down

0 comments on commit 757aa70

Please sign in to comment.