aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/util/History.ts6
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx32
2 files changed, 22 insertions, 16 deletions
diff --git a/src/client/util/History.ts b/src/client/util/History.ts
index e6f75a7db..632348306 100644
--- a/src/client/util/History.ts
+++ b/src/client/util/History.ts
@@ -58,8 +58,10 @@ export namespace HistoryUtil {
export function getState(): ParsedUrl {
const state = copyState(history.state);
- state.initializers = state.initializers || {};
- return state;
+ if (state) {
+ state.initializers = state.initializers || {};
+ }
+ return state ?? {initializers:{}};
}
// export function addHandler(handler: (state: ParsedUrl | null) => void) {
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 4119fb5ba..d2687df17 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -188,10 +188,13 @@ export class CollectionDockingView extends CollectionSubView() {
stack.addChild(docContentConfig, undefined);
stack.setActiveContentItem(stack.contentItems[stack.contentItems.length - 1]);
} else {
- const newItemStackConfig = { type: 'stack', content: [docContentConfig] };
- const newContentItem = glayRoot.layoutManager.createContentItem(newItemStackConfig, instance._goldenLayout);
+ const newContentItem = () => {
+ const newItem = glayRoot.layoutManager.createContentItem({ type: 'stack', content: [docContentConfig] }, instance._goldenLayout);
+ newItem.callDownwards('_$init');
+ return newItem;
+ }
if (glayRoot.contentItems.length === 0) { // if no rows / columns
- glayRoot.addChild(newContentItem);
+ glayRoot.addChild(newContentItem());
} else if (glayRoot.contentItems[0].isStack) {
glayRoot.contentItems[0].addChild(docContentConfig);
} else if (
@@ -203,32 +206,33 @@ export class CollectionDockingView extends CollectionSubView() {
else if (instance._goldenLayout.root.contentItems[0].isRow) { // if row
switch (pullSide) {
default:
- case "right": glayRoot.contentItems[0].addChild(newContentItem); break;
- case "left": glayRoot.contentItems[0].addChild(newContentItem, 0); break;
+ case "right": glayRoot.contentItems[0].addChild(newContentItem()); break;
+ case "left": glayRoot.contentItems[0].addChild(newContentItem(), 0); break;
case "top":
case "bottom":
// if not going in a row layout, must add already existing content into column
const rowlayout = glayRoot.contentItems[0];
const newColumn = rowlayout.layoutManager.createContentItem({ type: "column" }, instance._goldenLayout);
+ const newItem = newContentItem();
instance._goldenLayout.saveScrollTops(rowlayout.element);
rowlayout.parent.replaceChild(rowlayout, newColumn);
if (pullSide === "top") {
newColumn.addChild(rowlayout, undefined, true);
- newColumn.addChild(newContentItem, 0, true);
+ newColumn.addChild(newItem, 0, true);
} else if (pullSide === "bottom") {
- newColumn.addChild(newContentItem, undefined, true);
+ newColumn.addChild(newItem, undefined, true);
newColumn.addChild(rowlayout, 0, true);
}
instance._goldenLayout.restoreScrollTops(rowlayout.element);
rowlayout.config.height = 50;
- newContentItem.config.height = 50;
+ newItem.config.height = 50;
}
} else {// if (instance._goldenLayout.root.contentItems[0].isColumn) { // if column
switch (pullSide) {
- case "top": glayRoot.contentItems[0].addChild(newContentItem, 0); break;
- case "bottom": glayRoot.contentItems[0].addChild(newContentItem); break;
+ case "top": glayRoot.contentItems[0].addChild(newContentItem(), 0); break;
+ case "bottom": glayRoot.contentItems[0].addChild(newContentItem()); break;
case "left":
case "right":
default:
@@ -236,23 +240,23 @@ export class CollectionDockingView extends CollectionSubView() {
const collayout = glayRoot.contentItems[0];
const newRow = collayout.layoutManager.createContentItem({ type: "row" }, instance._goldenLayout);
+ const newItem = newContentItem();
instance._goldenLayout.saveScrollTops(collayout.element);
collayout.parent.replaceChild(collayout, newRow);
if (pullSide === "left") {
newRow.addChild(collayout, undefined, true);
- newRow.addChild(newContentItem, 0, true);
+ newRow.addChild(newItem, 0, true);
} else {
- newRow.addChild(newContentItem, undefined, true);
+ newRow.addChild(newItem, undefined, true);
newRow.addChild(collayout, 0, true);
}
instance._goldenLayout.restoreScrollTops(collayout.element);
collayout.config.width = 50;
- newContentItem.config.width = 50;
+ newItem.config.width = 50;
}
}
instance._ignoreStateChange = JSON.stringify(instance._goldenLayout.toConfig());
- newContentItem.callDownwards('_$init');
}
return instance.layoutChanged();