annotorious / annotorious-openseadragon

An OpenSeadragon plugin for annotating high-res zoomable images
https://annotorious.github.io
BSD 3-Clause "New" or "Revised" License
121 stars 43 forks source link

Cannot select an annotation inside another annotation #175

Open RahelaPogacean opened 1 year ago

RahelaPogacean commented 1 year ago

Hello!

I am using Annotorius with OpenSeadragon in my Angular application and I encountered the following issue: if I create an annotation inside another one, I am not able to select the inner annotation. The problem comes when I create the bigger annotation firstly and after that, the smaller/inner one. When I firstly create the smaller annotation and after that, the bigger one, both annotations are perfectly selected.

Any ideas how to manage to select both annotations in all situations?

DiegoPino commented 1 year ago

@RahelaPogacean hi. I'm using an older version in production (2.5.16) and don't have that issue. Tested interactively any combination and I get to select all of them independently of the order, so I have a few questions:

I have not overly tested the newer code (I really love when a piece of code/version works for us, and kinda stick with it, sorry!) but I would suggest:

https://github.com/annotorious/annotorious-openseadragon/commit/d2ad213a0ada712001677cb5fbb34046ee9b9f03#diff-bf33addc32978ffda1071f72299d6302476ce1ee1c6e0032adde06654454cfd1R283-R284

My brain tells me (incorrectly sometimes) that preventing a default (which might allow another event listener to delegate? who knows right)? might interfere in some ways. But that said, if the issue is not the code itself, debugging that part of the code I pointed might help you see who/when/why your inner annotation is not selected

Sorry for not being of more help

RahelaPogacean commented 1 year ago

@DiegoPino thank you for your response! When hovering over the inner annotation, it is not highlighted. And I also tried with your version and the selection is not working on the case I presented. I forgot to mention that the inner annotation is not selected for freeform and better polygon annotations.

DiegoPino commented 1 year ago

@RahelaPogacean ok, that helps! I will check with polygons. Maybe the bounding box for those is not calculated in the same way. Might take me a few hours (busy day)

RahelaPogacean commented 1 year ago

@DiegoPino thank you, I am waiting for your response

DiegoPino commented 1 year ago

Hi, sorry for the delay here. I really can't reproduce the issue you are having. See attached recording

https://github.com/annotorious/annotorious-openseadragon/assets/6946023/0c298610-17ae-45c1-9513-2fa5b1a51460

Anything that you have customized (CSS/ other DOM elements on top?, custom plugins)? that you could share/could help me, at least, to reproduce the error?

RahelaPogacean commented 1 year ago

@DiegoPino This is the way I create and select annotations. As you can see, the second scenario doesn't work, Here there are also the styles that I use in my application, which are still work in progress. Thank you and waiting for your feedback.

https://github.com/annotorious/annotorious-openseadragon/assets/33206716/cd716cf3-ffb5-4c80-b7a1-289b2dd569d4

styles.txt

rsimon commented 1 year ago

Thanks for posting this. Looks like it might be related to the freehand tool then. Annotorious sorts annotations by size, in order to ensure that the smallest is always on top. My guess is that something's wrong with the area calculation code in the freehand plugin, which would then cause that behavior.

RahelaPogacean commented 1 year ago

@rsimon This is also reproducing for better polygon.

rsimon commented 1 year ago

Hm. Well that's weird then. Polygon area computation is definitely working. Do you have any errors on the console? If anything breaks e.g. in your "onSelectionCreated" or "onAnnotationCreated" handlers, this would stop further execution and could cause Annotorious to not run the sorting.

RahelaPogacean commented 1 year ago

I don't have any errors

DiegoPino commented 1 year ago

@RahelaPogacean any chance you can share your WIP code?