Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filter out undefined instances when redrawing all charts (#7779) (CP: 24.4) #7795

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/charts/src/vaadin-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,14 @@ class Chart extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))) {
args.forEach((arg) => inflateFunctions(arg));
functionToCall.apply(this.configuration, args);
if (redrawCharts) {
Highcharts.charts.forEach((c) => c.redraw());
Highcharts.charts.forEach((c) => {
// Ignore `undefined` values that are preserved in the array
// after their corresponding chart instances are destroyed.
// See https://github.com/vaadin/flow-components/issues/6607
if (c !== undefined) {
c.redraw();
}
});
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion packages/charts/test/private-api.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from '@esm-bundle/chai';
import { fixtureSync, oneEvent } from '@vaadin/testing-helpers';
import { fixtureSync, nextFrame, oneEvent } from '@vaadin/testing-helpers';
import '../vaadin-chart.js';
import { inflateFunctions } from '../src/helpers.js';

Expand Down Expand Up @@ -193,5 +193,18 @@ describe('vaadin-chart private API', () => {
const legend = chart.$.chart.querySelector('.highcharts-legend-item > text').textContent;
expect(legend).to.be.equal('value');
});

it('should not throw when calling after a chart is destroyed', async () => {
chart.updateConfiguration({}, true);
await nextFrame();

expect(() => {
chart.constructor.__callHighchartsFunction('setOptions', true, {
lang: {
shortWeekdays: ['su', 'ma', 'ti', 'ke', 'to', 'pe', 'la'],
},
});
}).to.not.throw(Error);
});
});
});
Loading