recogito / text-annotator-js

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

Added annotation discarding when the selection collapses #140

Closed oleksandr-danylchenko closed 1 month ago

oleksandr-danylchenko commented 3 months ago

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

Changes Made

I added explicit deletion of the annotation that was created during the selection that collapsed. It removes zombie 1-char annotation when you switch the selection direction.

oleksandr-danylchenko commented 3 months ago

Discovered a bug that falsely deletes annotations in Firefox and Safari, but not Chrome:

https://github.com/user-attachments/assets/1171ce99-e8a7-4cb4-8994-b5fe526e0932

https://github.com/user-attachments/assets/6cb05779-2c28-4d90-ae7d-ad1379045d4e


The difference is that Chrome, when you click a mouse - immediately dispatches the selectstart event, creating the new currentTarget: image However, in FF & Safari, the start isn't dispatched, therefore, it thinks that the selection range collapsed for the previous annotation... 💀