recogito / text-annotator-js

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

Added missing previous selection discard upon the new selection change #155

Closed oleksandr-danylchenko closed 1 month ago

oleksandr-danylchenko commented 1 month ago

Issue

Initially reported - https://github.com/recogito/text-annotator-js/pull/151#discussion_r1795661665

We need to restore the selection.clear() call if there's nothing to update. Because now the previous, "discarded selection" unexpectedly stays up until you create a brand-new one.

https://github.com/user-attachments/assets/cb0d6edc-5a48-400b-90f8-a61c41251200

*in my testing env, the annotations that don't have either a highlight or a note assigned get automatically garbage collected when they get unselected

Can be reproduced in the playground:

https://github.com/user-attachments/assets/81bf9fc7-380d-4438-a81e-d0d6365b251d

rsimon commented 1 month ago

Thanks - yes, that makes sense. The previous selection should clear as soon as you start the next, not after you complete it.

oleksandr-danylchenko commented 1 month ago
oleksandr-danylchenko commented 1 month ago

Another mobile quirk! On iOS the ordering is the same as on Android - the selection comes after the pointer events. BUTT! It fluctuates depending on where and how fast you click! When you click over an annotation quickly - only pointerdown/pointerup are dispatched. But when slowly - all 4. When I tap over the textual content - all 4.

https://github.com/user-attachments/assets/cac92b06-5989-46d4-a7c8-9798723ea18f