Skip to content

Keep the editor over the next annotation after redraw - #8224

Open
pinelliazz wants to merge 2 commits into
plotly:mainfrom
pinelliazz:oss/5434-annotation-editor-reviewed
Open

pinelliazz wants to merge 2 commits into
plotly:mainfrom
pinelliazz:oss/5434-annotation-editor-reviewed

Conversation

@pinelliazz

@pinelliazz pinelliazz commented Dec 3, 2026 •

Copy link
Copy Markdown

Description

Fix the annotation editor position when clicking another annotation while an existing edit is active.

Saving the previous edit can redraw the plot, leaving the pending click attached to a removed SVG node. This change forwards the click to the matching annotation node that is still attached to the graph.

Closes #5434

Changes

  • Match the current annotation by input or template identity before forwarding the click.
  • Ignore clicks when the replacement node is missing or detached.
  • Add regression tests for editor alignment after redraw and detached annotation layers.

Screenshots/Videos

Before

upstream-df22b389-ordinary-a-to-b

After

final-0aeb642c-ordinary-a-to-b

Testing

  1. Open an editable plot with two annotations.
  2. Edit the first annotation and click the second without pressing Enter.
  3. Verify that the editor appears over the second annotation and that both edits are saved.

Local checks passed with Node 22.23.0:

  • Annotation tests: 46 passed.
  • SVG text and 3D interaction tests: 91 passed.
  • Lint, typecheck, syntax and schema checks.

Notes

  • If a template redraw changes the target annotation's index, a second click may be needed to start editing.
  • AI assistance: OpenAI Codex was used for implementation and testing. Antigravity and a separate Codex session were used for independent review.

Checklist

  • The linked issue has the ready-for-pr label, and it has no assignee or lists me as an assignee
  • I opened the pull request from a branch other than main in my fork
  • I selected "Allow edits from maintainers"
  • I did not edit files in dist/
  • I committed package-lock.json only for a dependency change
  • I added a file to draftlogs/ as draftlogs/README.md describes, or I will add one after the pull request opens

A click can arrive after relayout replaces the annotation node. Open the editor only on the matching annotation that is still in the graph.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Focusing an annotation while editing another annotation places the editable text elsewhere

1 participant