Skip to content

Fix hitboxes for aligned vertical legend labels - #12316

Open
pentaoa wants to merge 1 commit into
chartjs:masterfrom
pentaoa:fix/aligned-legend-hitboxes
Open

pentaoa wants to merge 1 commit into
chartjs:masterfrom
pentaoa:fix/aligned-legend-hitboxes

Conversation

@pentaoa

@pentaoa pentaoa commented Sep 22, 2026

Copy link
Copy Markdown

Vertical legends can draw a short center- or right-aligned label outside its clickable area. Compute the hitbox from the union of the symbol and the aligned text, honoring per-item alignment and RTL positioning.

Fixes #12067.

Adds regression coverage for every legend position, left/center/right alignment, RTL, and per-item alignment. Eight alignment cases fail on the original code. The tests check the rendered text edges and symbol centers.

Validation on the fork:

  • Lint, build, type checks, and integration tests passed in this run.
  • Complete browser tests: Chrome 1,728 passed; Firefox 1,727 passed with one existing image-test failure. All legend tests passed in both browsers.
  • The Firefox failure, controller.polarArea/pointLabels/overlapping.js, reproduced on the unchanged base in the same runner with the identical 293-pixel difference (0.11%, tolerance 0.1%). The fixture and tolerance are unchanged.

This change and its tests were developed with OpenAI Codex.

Cover aligned text and symbols while preserving RTL positioning. Add rendered-label regression coverage.

Assisted-by: OpenAI Codex
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.

Wrong legend hitbox area when using textAlign right/center

1 participant