recogito / text-annotator-js

A JavaScript library for text annotation.
BSD 3-Clause "New" or "Revised" License
21 stars 7 forks source link

#133 Fixed missing annotation dismissal clicking outside of the annotator `container` (vol.2) #149

Closed oleksandr-danylchenko closed 1 month ago

oleksandr-danylchenko commented 2 months ago

Issue - https://github.com/recogito/text-annotator-js/issues/133

Changes Made

To capture the actual lastPointerDown event on the page and make the correct timeDifference calculations, I added pointerdown event to the document scope.

In that way, the "click" will be properly recognized in the pointerup handler and the selection will be dismissed. As there will be no annotation under the pointer.


However, we should capture the pointerdown only on the elements that are not located within thenot-annotatable tree! Otherwise, it would be possible to unexpectedly dismiss the selected annotation while a user quickly drags from the input/textarea/button, etc. onto the textual content! More details with demo - https://github.com/recogito/text-annotator-js/pull/135#issuecomment-2327121736