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
Issue - https://github.com/recogito/text-annotator-js/issues/133
Changes Made
To capture the actual
lastPointerDown
event on the page and make the correcttimeDifference
calculations, I addedpointerdown
event to thedocument
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 theinput
/textarea
/button
, etc. onto the textual content! More details with demo - https://github.com/recogito/text-annotator-js/pull/135#issuecomment-2327121736