Skip to content

Commit

Permalink
Added ignoring pointerdown on not-annotatable
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-danylchenko committed Sep 3, 2024
1 parent 694247d commit ed63ccd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/text-annotator/src/SelectionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ export const SelectionHandler = (
// Therefore, to prevent right-click selection, we need to listen
// to the initial pointerdown event and remember the button
const onPointerDown = (evt: PointerEvent) => {
const annotatable = !(evt.target as Node).parentElement?.closest(NOT_ANNOTATABLE_SELECTOR);
if (!annotatable) return;

// Note that the event itself can be ephemeral!
const { target, timeStamp, offsetX, offsetY, type } = evt;
lastPointerDown = { ...evt, target, timeStamp, offsetX, offsetY, type };
Expand All @@ -125,8 +128,7 @@ export const SelectionHandler = (

const onPointerUp = (evt: PointerEvent) => {
const annotatable = !(evt.target as Node).parentElement?.closest(NOT_ANNOTATABLE_SELECTOR);
if (!annotatable || !isLeftClick)
return;
if (!annotatable || !isLeftClick) return;

// Logic for selecting an existing annotation by clicking it
const clickSelect = () => {
Expand Down

0 comments on commit ed63ccd

Please sign in to comment.