Skip to content

Commit 3229e73

Browse files
authored
fix: force size calculation on chart reattach (#10323)
1 parent de570b5 commit 3229e73

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/charts/src/vaadin-chart-mixin.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,10 @@ export const ChartMixin = (superClass) =>
795795
// Detect if the chart had already been initialized. This might happen in
796796
// environments where the chart is lazily attached (e.g Grid).
797797
if (this.configuration) {
798-
this.__reflow();
798+
const { height } = this.$.wrapper.style;
799+
this.$.wrapper.style.height = '';
800+
this.configuration.setSize(null, null, false);
801+
this.$.wrapper.style.height = height;
799802
return;
800803
}
801804

packages/charts/test/reattach.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,24 @@ describe('reattach', () => {
260260
expect(chart.configuration.inverted).to.be.undefined;
261261
});
262262

263+
it('should restore default height when moving from different container with defined height', async () => {
264+
await oneEvent(chart, 'chart-load');
265+
266+
const initialHeight = getComputedStyle(chart).height;
267+
268+
inner.style.height = '700px';
269+
inner.appendChild(chart);
270+
await nextFrame();
271+
272+
expect(getComputedStyle(chart).height).to.be.equal(inner.style.height);
273+
274+
// Move back to first parent
275+
wrapper.appendChild(chart);
276+
await nextFrame();
277+
278+
expect(getComputedStyle(chart).height).to.be.equal(initialHeight);
279+
});
280+
263281
describe('series', () => {
264282
let series;
265283

0 commit comments

Comments
 (0)