Skip to content

Fix #10297: dispatch canvas.zoom event on double-click annotation zoom#10403

Open
DanielBorgs wants to merge 1 commit intocvat-ai:developfrom
DanielBorgs:issue-10297
Open

Fix #10297: dispatch canvas.zoom event on double-click annotation zoom#10403
DanielBorgs wants to merge 1 commit intocvat-ai:developfrom
DanielBorgs:issue-10297

Conversation

@DanielBorgs
Copy link
Copy Markdown

@DanielBorgs DanielBorgs commented Mar 23, 2026

Motivation and context

Fixes #10297

When zooming into an annotation via double-click, issue labels shown in review mode would incorrectly scale up with the canvas transform. This happened because the onFocusRegion method in canvasView.ts was not dispatching the canvas.zoom custom event after zooming, unlike the scroll wheel zoom handler which already dispatched it correctly.

The canvas.zoom event is used by the UI to recalculate and counteract the CSS transform applied to issue labels, keeping their font size constant regardless of zoom level. Since onFocusRegion never fired this event, the labels would scale up visually when using double-click zoom.

The fix dispatches canvas.zoom at the end of onFocusRegion, matching the existing behavior of the scroll wheel zoom handler.

How has this been tested?

Manual testing:

Created a task, opened a job in review mode, created an issue on an annotation, and verified that double-click zooming no longer scales up the issue label text.

Automated testing:

Added a Cypress e2e test in tests/cypress/e2e/issues_prs2/issue_10297_zooming_in_onto_annotation_increases_issue_text_size.js that patches EventTarget.prototype.dispatchEvent and asserts that a canvas.zoom event is fired when double-clicking an annotation shape.

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
    [ ] I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

When zooming into an annotation via double-click, the onFocusRegion
method in canvasView.ts was not dispatching the 'canvas.zoom' custom
event. This caused the UI to skip the font-size recalculation for
issue labels, making them scale up with the canvas transform instead
of staying at a fixed size.

Scroll wheel zoom already dispatched 'canvas.zoom' correctly, which
is why the bug was only reproducible with double-click zoom.

The fix dispatches 'canvas.zoom' at the end of onFocusRegion, in the
same way it is dispatched in the scroll wheel zoom handler.
@DanielBorgs
Copy link
Copy Markdown
Author

Hi @bsekachev, @nmanovic, just pinging on this for a review when you have a chance! Let me know if you need any adjustments.

Also, the rest_api_testing job failed due to a transient Docker Hub TLS timeout when pulling the cvat_opa image, unrelated to these changes. I believe a rerun should be enough to clear it.

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.

Zooming-in onto an annotation increases issue text size

1 participant