From 33f056a187e8c83d8b739a94baacca392cf0b6b7 Mon Sep 17 00:00:00 2001 From: Cyprien P Date: Wed, 22 Sep 2021 12:58:43 +0200 Subject: [PATCH] (core) Fix js errors when (un)summarizing underlying table of charts Summary: Used to throw js errors: `Resize must be passed a displayed plot div element.` Summarizing (or unsummarizing) causes the ChartView view instance to be replace by a new one in the view layout. However, the problem is that the old view instance get disposed only after the new view instance is added to the view layout. This causes the old view layout to try to resize chart while chart dom has been removed from the dom (which Plotly does not support). This diff fixes it by checking the the chart dom elemnt is still in the dom before making the plotly call to resize the chart. TODO: It feels weird that the old view instance gets disposed after the new one get added. Maybe we should check that also. Test Plan: New test added. Reviewers: dsagal Reviewed By: dsagal Subscribers: dsagal Differential Revision: https://phab.getgrist.com/D3035 --- app/client/components/ChartView.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/components/ChartView.ts b/app/client/components/ChartView.ts index 0e756d3f..52935cba 100644 --- a/app/client/components/ChartView.ts +++ b/app/client/components/ChartView.ts @@ -206,7 +206,7 @@ export class ChartView extends Disposable { } private _resizeChart() { - if (this.isDisposed() || !Plotly) { return; } + if (this.isDisposed() || !Plotly || !this._chartDom.parentNode) { return; } Plotly.Plots.resize(this._chartDom); } }