From 52d3f6320339b23ed0155009f45ff7121d90e3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Wed, 29 Dec 2021 21:05:30 +0100 Subject: [PATCH] (core) Fixing bug with deleting charts Summary: Fix for a bug. When a chart had a "Group Data" checked, deleting it produced a JS error. Test Plan: browser test Reviewers: cyprien Reviewed By: cyprien Differential Revision: https://phab.getgrist.com/D3200 --- app/client/components/ChartView.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/client/components/ChartView.ts b/app/client/components/ChartView.ts index fb8413ed..58d070d6 100644 --- a/app/client/components/ChartView.ts +++ b/app/client/components/ChartView.ts @@ -403,11 +403,12 @@ export class ChartConfig extends GrainJSDisposable { ) ); - // The column id of the grouping column, or -1 if multiseries is disabled. + // The column id of the grouping column, or -1 if multiseries is disabled or there are no viewFields, + // for example during section removal. private _groupDataColId: Computed = Computed.create(this, (use) => { const multiseries = use(this._optionsObj.prop('multiseries')); const viewFields = use(use(this._section.viewFields).getObservable()); - if (!multiseries) { return -1; } + if (!multiseries || viewFields.length === 0) { return -1; } return use(viewFields[0].column).getRowId(); }) .onWrite((colId) => this._setGroupDataColumn(colId));