Skip to content

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

Open
kwy404 wants to merge 1 commit into
chartjs:masterfrom
kwy404:fix-debounce-delayed-args
Open

kwy404 wants to merge 1 commit into
chartjs:masterfrom
kwy404:fix-debounce-delayed-args

Conversation

@kwy404

@kwy404 kwy404 commented Sep 27, 2026

Copy link
Copy Markdown

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.

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