chartjs / chartjs/Chart.js

Wrong legend hitbox area when using textAlign right/center

Open
#12,067 1 comment 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

### Expected behavior

The entire legend item text should be clickable when centering or right-aligning the text.

For example:

![Image](https://github.com/user-attachments/assets/1f7ccb53-1689-417a-ab92-e4bfde33d27d)

### Current behavior

The clickable area of ​​the legend item is smaller than it should be, as if the text were always left-aligned.

![Image](https://github.com/user-attachments/assets/c8f7bef3-79cf-4746-b807-ceaf6f9ba9f9)

Also occurs in RTL mode:

![Image](https://github.com/user-attachments/assets/b228eb23-12b3-42d0-a4e5-0298ab209e8c)

### Reproducible sample

https://codepen.io/adrianbrs/pen/KwwzRja

### Optional extra steps/info to reproduce

_No response_

### Possible solution

_No response_

### Context

_No response_

### chart.js version

v4.4.9

### Browser name and version

Google Chrome 135.0.7049.95 (64 bits)

### Link to your project

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.