(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
This commit is contained in:
Jarosław Sadziński 2021-12-29 21:05:30 +01:00
parent 24c57e05d7
commit 52d3f63203

View File

@ -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<number> = 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));