Skip to content

Close annotation details when the selected annotation is removed #575

Description

@coderabbitai

Summary

In Diva 7.5.2, the annotation details panel can remain open after the selected annotation is removed. This is an upstream annotation lifecycle issue, not a defect in Cantus OMR highlight rendering.

Affected area

src/viewer-element.ts, class OsdViewer:

  • setAnnotations replaces canvas annotation data and updates overlays without clearing a selection that no longer exists.
  • setTileSources clears annotation data without closing the annotation panel or clearing selectedAnnotationId.

Reproduction

  1. Load a canvas with an annotation.
  2. Select the annotation to open its details panel.
  3. Replace that canvas's annotations with an empty list.
  4. Observe that the overlay disappears but the details panel remains open with the removed annotation's content.

Changing tile sources after opening the panel can also leave stale annotation details visible.

Required changes

After replacing canvas annotations, check whether the selected annotation still exists across the stored canvas annotations. If it does not, clear selectedAnnotationId and close the annotation panel. Apply the same cleanup when setTileSources clears annotation data.

Preserve the selection when the selected annotation still exists, including when annotations on an unrelated canvas change.

Acceptance criteria

  • Removing the selected annotation closes its details panel and clears its selection.
  • Replacing tile sources closes stale annotation details and clears the selection.
  • Updating an unrelated canvas does not clear a valid selection.
  • Add regression coverage for these annotation lifecycle cases.

Context

Filed at @ahankinson's request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions