From 0e41d6ba98090ef6139a3d99357e31a9d6e777b8 Mon Sep 17 00:00:00 2001 From: kwy404 Date: Sun, 27 Sep 2026 00:56:16 -0300 Subject: [PATCH] Fix resize update mode being an array when resizeDelay is set --- src/helpers/helpers.extras.ts | 2 +- test/specs/core.controller.tests.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/helpers/helpers.extras.ts b/src/helpers/helpers.extras.ts index 798e10c1e86..b0c426d4810 100644 --- a/src/helpers/helpers.extras.ts +++ b/src/helpers/helpers.extras.ts @@ -52,7 +52,7 @@ export function debounce>(fn: (...args: TArgs) => void, return function(...args: TArgs) { if (delay) { clearTimeout(timeout); - timeout = setTimeout(fn, delay, args); + timeout = setTimeout(fn, delay, ...args); } else { fn.apply(this, args); } diff --git a/test/specs/core.controller.tests.js b/test/specs/core.controller.tests.js index d1b2e424603..b7b5d7407a5 100644 --- a/test/specs/core.controller.tests.js +++ b/test/specs/core.controller.tests.js @@ -694,6 +694,32 @@ describe('Chart', function() { wrapper.style.width = '455px'; }); + it('should call update with the resize mode when resizeDelay is set', function(done) { + var chart = acquireChart({ + options: { + responsive: true, + maintainAspectRatio: false, + resizeDelay: 10 + } + }, { + canvas: { + style: '' + }, + wrapper: { + style: 'width: 300px; height: 350px; position: relative' + } + }); + + spyOn(chart, 'update').and.callThrough(); + waitForResize(chart, function() { + setTimeout(function() { + expect(chart.update).toHaveBeenCalledWith('resize'); + done(); + }, 50); + }); + chart.canvas.parentNode.style.width = '455px'; + }); + it('should restore the original size when parent became invisible', function(done) { var chart = acquireChart({ options: {