(core) Fixing couple of bugs in collapsed section layout

Summary:
The previous implementation for collapsing sections involved disposing of a view instance (Grid or Chart component). This caused numerous bugs with
linking sections as the implementation is located in the BaseView.js. Now the view instance is kept and attached to a dom in a hidden div, so it can respond
and function as a normal rendered section. It is also passed from between collapsed and main layout, when sections are dragged or moved using section's
menu commands (`collapse` and `add to main page`)

It also implies that the ViewLayout must still be rendered when a section is maximized (as it is responsible for the view instance), so the dom, and
some logic for rendering it, had to be changed.

Test Plan: New and updated

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3826
This commit is contained in:
Jarosław Sadziński
2023-03-22 16:21:53 +01:00
parent be8e13df64
commit a9ff6b9a84
11 changed files with 364 additions and 138 deletions

View File

@@ -128,7 +128,16 @@ class PageRecWrapper implements ISearchablePageRec {
}
public viewSections(): ViewSectionRec[] {
return this._page.view.peek().viewSections.peek().peek();
const sections = this._page.view.peek().viewSections.peek().peek();
const collapsed = new Set(this._page.view.peek().activeCollapsedSections.peek());
const activeSectionId = this._page.view.peek().activeSectionId.peek();
// If active section is collapsed, it means it is rendered in the popup, so narrow
// down the search to only it.
const inPopup = collapsed.has(activeSectionId);
if (inPopup) {
return sections.filter((s) => s.getRowId() === activeSectionId);
}
return sections.filter((s) => !collapsed.has(s.getRowId()));
}
public activeSectionId() {