From 9a40f051dd1630c0c1675353a420bd524601b505 Mon Sep 17 00:00:00 2001 From: bobzel Date: Sat, 21 Nov 2020 11:05:20 -0500 Subject: fixed issue with tabs disappearing from Off-Screen tab list --- .../views/collections/CollectionDockingView.tsx | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/client/views/collections/CollectionDockingView.tsx') diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index abe8477e4..0fa969f13 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -4,7 +4,7 @@ import { action, IReactionDisposer, observable, reaction, runInAction } from "mo import { observer } from "mobx-react"; import * as ReactDOM from 'react-dom'; import * as GoldenLayout from "../../../client/goldenLayout"; -import { Doc, DocListCast, Opt } from "../../../fields/Doc"; +import { Doc, DocListCast, Opt, DocListCastAsync } from "../../../fields/Doc"; import { Id } from '../../../fields/FieldSymbols'; import { InkTool } from '../../../fields/InkField'; import { List } from '../../../fields/List'; @@ -369,16 +369,18 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) { const docs = !docids ? [] : docids.map(id => DocServer.GetCachedRefField(id)).filter(f => f).map(f => f as Doc); this.props.Document.dockingConfig = json; - const sublists = DocListCast(this.props.Document[this.props.fieldKey]); - const tabs = Cast(sublists[0], Doc, null); - const other = Cast(sublists[1], Doc, null); - const tabdocs = DocListCast(tabs.data); - const otherdocs = DocListCast(other.data); - Doc.GetProto(tabs).data = new List(docs); - const otherSet = new Set(); - otherdocs.filter(doc => !docs.includes(doc)).forEach(doc => otherSet.add(doc)); - tabdocs.filter(doc => !docs.includes(doc)).forEach(doc => otherSet.add(doc)); - Doc.GetProto(other).data = new List(Array.from(otherSet.values())); + setTimeout(async () => { + const sublists = DocListCast(this.props.Document[this.props.fieldKey]); + const tabs = Cast(sublists[0], Doc, null); + const other = Cast(sublists[1], Doc, null); + const tabdocs = await DocListCastAsync(tabs.data); + const otherdocs = await DocListCastAsync(other.data); + Doc.GetProto(tabs).data = new List(docs); + const otherSet = new Set(); + otherdocs?.filter(doc => !docs.includes(doc)).forEach(doc => otherSet.add(doc)); + tabdocs?.filter(doc => !docs.includes(doc)).forEach(doc => otherSet.add(doc)); + Doc.GetProto(other).data = new List(Array.from(otherSet.values())); + }, 0); } tabDestroyed = (tab: any) => { -- cgit v1.2.3-70-g09d2 From 4835cefd9cab01de2ffd9f9ceb0962dc99b00928 Mon Sep 17 00:00:00 2001 From: bobzel Date: Sat, 21 Nov 2020 20:39:00 -0500 Subject: fixed goldenLayout to remove rowCol when removing a stack if the rowCol's parent contains only the rowCol. prevented unlocking documents from setting NativeWidth/Height --- src/client/goldenLayout.js | 11 ++++++++++- src/client/views/GlobalKeyHandler.ts | 2 +- src/client/views/collections/CollectionDockingView.tsx | 4 +++- src/client/views/nodes/DocumentView.tsx | 8 ++++---- 4 files changed, 18 insertions(+), 7 deletions(-) (limited to 'src/client/views/collections/CollectionDockingView.tsx') diff --git a/src/client/goldenLayout.js b/src/client/goldenLayout.js index 293762709..97ce13ae1 100644 --- a/src/client/goldenLayout.js +++ b/src/client/goldenLayout.js @@ -3204,7 +3204,16 @@ * If this was the last content item, remove this node as well */ } else if (!(this instanceof lm.items.Root) && this.config.isClosable === true) { - if (!this.parent.parent.isRoot || this.parent.contentItems.length > 1) this.parent.removeChild(this); // bcz: added test for last stack + const stack = this; + const rowOrCol = stack.parent; + const parRowOrCol = rowOrCol.parent; + const canDelete = rowOrCol && !rowOrCol.isRoot && (rowOrCol.contentItems.length > 1 || (parRowOrCol && parRowOrCol.contentItems.length > 1)); // bcz: added test for last stack + if (canDelete) { + rowOrCol.removeChild(stack); + if (rowOrCol.contentItems.length === 1 && parRowOrCol.contentItems.length === 1 && !parRowOrCol.isRoot) { + parRowOrCol.replaceChild(rowOrCol, rowOrCol.contentItems[0]); + } + } } }, diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts index fb360ee26..522900fd2 100644 --- a/src/client/views/GlobalKeyHandler.ts +++ b/src/client/views/GlobalKeyHandler.ts @@ -56,7 +56,7 @@ export class KeyManager { public handle = action(async (e: KeyboardEvent) => { if (e.key?.toLowerCase() === "shift" && e.ctrlKey && e.altKey) KeyManager.Instance.ShiftPressed = true; - if (!Doc.UserDoc().noviceMode && e.key.toLocaleLowerCase() === "shift") DocServer.UPDATE_SERVER_CACHE(true); + //if (!Doc.UserDoc().noviceMode && e.key.toLocaleLowerCase() === "shift") DocServer.UPDATE_SERVER_CACHE(true); const keyname = e.key && e.key.toLowerCase(); this.handleGreedy(keyname); diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index 0fa969f13..57b038c73 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -172,7 +172,9 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) { instance._goldenLayout.root.addChild(newContentItem); } else if (instance._goldenLayout.root.contentItems[0].isStack) { instance._goldenLayout.root.contentItems[0].addChild(docContentConfig); - } else if (instance._goldenLayout.root.contentItems.length === 1 && instance._goldenLayout.root.contentItems[0].contentItems.length === 1 && + } else if ( + instance._goldenLayout.root.contentItems.length === 1 && + instance._goldenLayout.root.contentItems[0].contentItems.length === 1 && instance._goldenLayout.root.contentItems[0].contentItems[0].contentItems.length === 0) { instance._goldenLayout.root.contentItems[0].contentItems[0].addChild(docContentConfig); } diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 9b26094b3..7ef17c389 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -757,10 +757,10 @@ export class DocumentView extends DocComponent(Docu this.Document._overflow = !layers.includes("background") ? "visible" : undefined; if (!layers.includes("background")) { this.props.bringToFront(this.props.Document, true); - const wid = this.Document[WidthSym](); // change the nativewidth and height if the background is to be a collection that aggregates stuff that is added to it. - const hgt = this.Document[HeightSym](); - Doc.SetNativeWidth(this.props.Document[DataSym], wid); - Doc.SetNativeHeight(this.props.Document[DataSym], hgt); + // const wid = this.Document[WidthSym](); // change the nativewidth and height if the background is to be a collection that aggregates stuff that is added to it. + // const hgt = this.Document[HeightSym](); + // Doc.SetNativeWidth(this.props.Document[DataSym], wid); + // Doc.SetNativeHeight(this.props.Document[DataSym], hgt); } } -- cgit v1.2.3-70-g09d2