From d08fdd772ed8eab224692611095cac924f446d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Fri, 17 Dec 2021 13:16:18 +0100 Subject: [PATCH] (core) Fixing bug with undoing page delation with a custom layout Summary: Fixing a bug: When removing a page with linked sections and then undoing, there are two JS errors raised: - flexSize is not a function - getter is not a function Test Plan: nbrowser tests Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3192 --- app/client/components/Layout.js | 3 +++ app/client/components/LinkingState.ts | 4 ++++ app/client/models/entities/ViewSectionRec.ts | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/client/components/Layout.js b/app/client/components/Layout.js index 1814d82a..312da743 100644 --- a/app/client/components/Layout.js +++ b/app/client/components/Layout.js @@ -439,6 +439,9 @@ Layout.prototype.buildLayout = function(boxSpec, needDynamic) { Layout.prototype._getBoxSpec = function(layoutBox) { var spec = {}; + if (layoutBox.isDisposed()) { + return spec; + } if (layoutBox.flexSize() && layoutBox.flexSize() !== 100) { spec.size = layoutBox.flexSize(); } diff --git a/app/client/components/LinkingState.ts b/app/client/components/LinkingState.ts index e6f3b8ac..05b4068c 100644 --- a/app/client/components/LinkingState.ts +++ b/app/client/components/LinkingState.ts @@ -138,6 +138,10 @@ export class LinkingState extends Disposable { ): ko.Computed { return this.autoDispose(ko.computed(() => { const srcRowId = this._srcSection.activeRowId(); + if (srcRowId === null) { + console.warn("_simpleFilter activeRowId is null"); + return { filters: {}, operations: {}}; + } const values = valuesFunc(srcRowId); return {filters: {[colId]: values}, operations: {[colId]: operation}} as FilterColValues; })); diff --git a/app/client/models/entities/ViewSectionRec.ts b/app/client/models/entities/ViewSectionRec.ts index 702e0f40..9bcc7d56 100644 --- a/app/client/models/entities/ViewSectionRec.ts +++ b/app/client/models/entities/ViewSectionRec.ts @@ -410,7 +410,7 @@ export function createViewSectionRec(this: ViewSectionRec, docModel: DocModel): this.linkSrcCol = refRecord(docModel.columns, this.activeLinkSrcColRef); this.linkTargetCol = refRecord(docModel.columns, this.activeLinkTargetColRef); - this.activeRowId = ko.observable(); + this.activeRowId = ko.observable(null); // If the view instance for this section is instantiated, it will be accessible here. this.viewInstance = ko.observable(null);