diff options
author | brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> | 2022-10-28 10:10:04 -0400 |
---|---|---|
committer | brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> | 2022-10-28 10:10:04 -0400 |
commit | ceb338752aacc383c97a0e3a9b608365a1cf39b6 (patch) | |
tree | d2f355b726a9b21950f332c0f65931d7d6eef515 /src/client/goldenLayout.js | |
parent | 5d6a0458b9d4f35e0c568a4d76d4fcab4e22f698 (diff) | |
parent | 2fc88a931cb2fc3408297b000208990633445585 (diff) |
merge
Diffstat (limited to 'src/client/goldenLayout.js')
-rw-r--r-- | src/client/goldenLayout.js | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/src/client/goldenLayout.js b/src/client/goldenLayout.js index 012ee163c..dd11e6466 100644 --- a/src/client/goldenLayout.js +++ b/src/client/goldenLayout.js @@ -3263,12 +3263,6 @@ 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) { - - saveScrollTops(rowOrCol.contentItems[0].element); - parRowOrCol.replaceChild(rowOrCol, rowOrCol.contentItems[0]); - restoreScrollTops(rowOrCol.contentItems[0].element); - } } } }, @@ -4062,6 +4056,14 @@ lm.items.AbstractContentItem.prototype.removeChild.call(this, contentItem, keepChild); if (this.contentItems.length === 1 && this.config.isClosable === true) { + if (["row","column"].includes(this.contentItems[0].type) || ["row","column"].includes(this.parent.type)) { + let parent = this.parent; + let correctRowOrCol = this.contentItems[0]; + saveScrollTops(correctRowOrCol.element); + parent.replaceChild(this, correctRowOrCol); + restoreScrollTops(correctRowOrCol.element); + } + // bcz: this has the effect of removing children from the DOM and then re-adding them above where they were before. // in the case of things like an iFrame with a YouTube video, the video will reload for now reason. So let's try leaving these "empty" rows alone. // childItem = this.contentItems[0]; @@ -4724,15 +4726,35 @@ */ } else { type = isVertical ? 'column' : 'row'; - rowOrColumn = this.layoutManager.createContentItem({ type: type }, this); - this.parent.replaceChild(this, rowOrColumn); + if (this.parent.contentItems.length === 1) { + let grandparent = this.parent.parent; + let correctRowOrCol = this.layoutManager.createContentItem({ type: type }, this); + grandparent.replaceChild(this.parent, correctRowOrCol); + correctRowOrCol.addChild(contentItem, 0, true); + let newstack = this.contentItems[0]; + if (newstack.isComponent) { + newstack = this.layoutManager.createContentItem({ + type: 'stack', + header: contentItem.config.header || {} + }, this); + newstack._$init(); + newstack.addChild(this.contentItems[0]); + } + correctRowOrCol.addChild(newstack, insertBefore ? 0 : undefined, true); + newstack.config[dimension] = 50; + contentItem.config[dimension] = 50; + correctRowOrCol.callDownwards('setSize'); + } else { + rowOrColumn = this.layoutManager.createContentItem({ type: type }, this); + this.parent.replaceChild(this, rowOrColumn); - rowOrColumn.addChild(contentItem, insertBefore ? 0 : undefined, true); - rowOrColumn.addChild(this, insertBefore ? undefined : 0, true); + rowOrColumn.addChild(contentItem, insertBefore ? 0 : undefined, true); + rowOrColumn.addChild(this, insertBefore ? undefined : 0, true); - this.config[dimension] = 50; - contentItem.config[dimension] = 50; - rowOrColumn.callDownwards('setSize'); + this.config[dimension] = 50; + contentItem.config[dimension] = 50; + rowOrColumn.callDownwards('setSize'); + } } }, |