diff --git a/packages/charts/src/vaadin-chart.js b/packages/charts/src/vaadin-chart.js index 4b43f6d7304..87dbb6bd260 100644 --- a/packages/charts/src/vaadin-chart.js +++ b/packages/charts/src/vaadin-chart.js @@ -1078,6 +1078,10 @@ class Chart extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))) { disconnectedCallback() { super.disconnectedCallback(); + if (this.configuration) { + this._jsonConfigurationBuffer = this.configuration.userOptions; + } + queueMicrotask(() => { if (this.isConnected) { return; diff --git a/packages/charts/test/reattach.test.js b/packages/charts/test/reattach.test.js index 3d3e8ce7e02..a04ee5852d7 100644 --- a/packages/charts/test/reattach.test.js +++ b/packages/charts/test/reattach.test.js @@ -186,6 +186,20 @@ describe('reattach', () => { expect(chart.configuration.options.plotOptions.series.stacking).to.be.equal('percent'); }); + it('should restore configuration done through `updateConfigaration` after reattach', async () => { + const wrapper = fixtureSync(`
`); + const chart = wrapper.firstElementChild; + chart.updateConfiguration({ title: { text: 'New title' }, series: [{ name: 'series', data: [1, 2, 3] }] }); + await nextFrame(); + wrapper.removeChild(chart); + await nextFrame(); + wrapper.appendChild(chart); + await nextFrame(); + expect(chart.configuration.options.title.text).to.be.equal('New title'); + expect(chart.configuration.options.series.length).to.be.equal(1); + expect(chart.configuration.options.series[0].name).to.be.equal('series'); + }); + it('should apply categories updated while detached after reattach', async () => { chart.categories = ['Jan', 'Feb', 'Mar']; await oneEvent(chart, 'chart-load');