Skip to content

Restore canvas text direction after legend and tooltip drawing - #12371

Open
hakarrr wants to merge 4 commits into
chartjs:masterfrom
hakarrr:fix-text-direction-restoration
Open

hakarrr wants to merge 4 commits into
chartjs:masterfrom
hakarrr:fix-text-direction-restoration

Conversation

@hakarrr

@hakarrr hakarrr commented Oct 26, 2026

Copy link
Copy Markdown

Description

Legend and tooltip drawing call overrideTextDirection, which saves the canvas's original CSS direction and priority on the context. Their restore calls currently pass the configured direction string, but restoreTextDirection treats that value as a [direction, priority] tuple. It consequently attempts to restore individual characters of "rtl" or "ltr", leaving the override on the canvas.

For example, an RTL legend on an LTR canvas causes a tooltip with no textDirection override to render "Hello, World!" as "!Hello, World". Drawing also leaves the canvas's inline direction changed, including its priority.

Default the helper's optional restoration tuple to the saved context value, and have both plugins call it without the direction string. Explicit tuple callers remain supported. No layout or configured text-direction behavior is changed.

The earlier report #7035 identified the call-signature mismatch. The #7030 change removed the helper's saved-context read; this restores that fallback while preserving the subsequently typed optional tuple parameter.

Tests

27 native Chrome cases cover legend and tooltip drawing with both directions, original CSS direction/priority, empty inline styles, explicit tuple compatibility, no saved override, and cross-plugin isolation. 21 fail on unchanged master; six are controls.

Fresh frozen-lockfile dependency install, full ChromeHeadless suite: 1730 passed. Rollup build, declaration emit and TypeScript noEmit passed. Changed-file ESLint has zero errors and five unchanged warnings (one unused parameter and four tooltip max-statements warnings). Firefox and downstream tests were not run. Local Chrome launcher settings are not included.

hakarrr and others added 4 commits October 26, 2026 21:46
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
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.

1 participant