Skip to content

Fix resize update mode being an array when resizeDelay is set - #12323

Merged
etimberg merged 1 commit into
chartjs:masterfrom
kwy404:fix-debounce-delayed-args
Nov 22, 2026
Merged

etimberg merged 1 commit into
chartjs:masterfrom
kwy404:fix-debounce-delayed-args

Conversation

@kwy404

@kwy404 kwy404 commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

When resizeDelay is set, the delayed resize runs chart.update(['resize']) instead of chart.update('resize').

Root cause: debounce in src/helpers/helpers.extras.ts schedules the delayed call with setTimeout(fn, delay, args). setTimeout passes its extra parameters to fn one by one, so fn gets the whole args array as its first argument. The branch without a delay uses fn.apply(this, args), so the two paths disagree. Because of this, the update hooks give plugins args.mode as ['resize'], scriptable options see context.mode as an array, and checks like mode !== 'resize' in the radar controller take the wrong branch.

Fix: spread the arguments, setTimeout(fn, delay, ...args), so the delayed call gets the same arguments as the direct one.

Test: a new spec in test/specs/core.controller.tests.js sets resizeDelay: 10, resizes the wrapper and expects chart.update to have been called with 'resize'. It fails before the fix (the only call was [ [ 'resize' ] ]) and passes after.

@kurkle kurkle closed this Nov 22, 2026
@kurkle kurkle reopened this Nov 22, 2026
@kurkle kurkle added this to the Version 4.6.2 milestone Nov 22, 2026
@kurkle
kurkle requested a review from etimberg November 22, 2026 20:25
@etimberg
etimberg merged commit 3802fa2 into chartjs:master Nov 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants