holoviz / holonote

Tools to create, edit, and persist annotated regions for HoloViews
https://holonote.holoviz.org
BSD 3-Clause "New" or "Revised" License
23 stars 2 forks source link

Edit mode when an annotation is selected erroneously allows for creation of new annotation #114

Closed droumis closed 4 months ago

droumis commented 4 months ago

Looks like the relevant change is here. Indeed, reverting this function resolves the issue. @ahuang11

Notice that in the "After #101" video below, the erroneously created annotation also goes to the wrong axis. This remains the case even with #113. But I guess it doesn't matter because the intended behavior is to not allow new drag-created annotations when an existing annotation is selected, and edit mode is active.

Code ## This code is a bit simpler than what is shown in the video because the tabulator app is not yet merged. ```python import holoviews as hv; hv.extension('bokeh') import panel as pn; pn.extension() import numpy as np from holonote.annotate import Annotator from holonote.app import PanelWidgets annotator = Annotator({"x": float, "y": float}, fields=["description"]) annotator_widgets = PanelWidgets(annotator) bounds = (-1, -1, 1, 1) data = np.array([[0, 1], [1, 0]]) img = hv.Image(data, kdims=['x', 'y'], bounds=bounds) img_right = hv.Image(data, kdims=['z', 'y'], bounds=bounds) # y as second kdim! so HSpan left_plot = annotator * img right_plot = annotator * img_right layout = left_plot + right_plot annotator.set_regions(x=(-0.15, 0.15), y=(-0.25, 0.25)) annotator.add_annotation(description="Test") pn.Column(annotator_widgets, layout) ```

Prior to #101 ✅

https://github.com/holoviz/holonote/assets/6613202/92ac1abf-e98e-4538-9584-2f0ba7f1efea

After #101 ❌

https://github.com/holoviz/holonote/assets/6613202/4a69bf7e-b6a9-4cea-acd2-90b65a1ec148

ahuang11 commented 4 months ago

Probably something related to https://github.com/holoviz/holonote/pull/101/files#diff-bb719105cbef9f78377af003eabcd4e554a21c3aba3c19c0fb92cac4666836f1L207-L217