Merge pull request #42 from BrhmDev/fix/rearrange-view-not-working-with-only-2-tabs

Fix rearrange view not working with only 2 tabs.
This commit is contained in:
mauro 🤙 2024-10-06 19:03:08 +02:00 committed by GitHub
commit 3676ca1418
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -443,20 +443,20 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
let nodeSize;
let newParent;
if (splitDirection === node.parent.direction) {
if (splitDirection === node.parent?.direction) {
newParent = node.parent;
nodeSize = node.sizeInParent;
} else {
nodeSize = 100;
const nodeIndex = node.parent.children.indexOf(node);
newParent = new SplitNode(splitDirection, node.sizeInParent);
if (node.parent) {
newParent.parent = node.parent;
const nodeIndex = node.parent.children.indexOf(node);
node.parent.children[nodeIndex] = newParent;
} else {
const viewData = Object.values(this._data).find(s => s.layoutTree === node.parent);
const viewData = Object.values(this._data).find(s => s.layoutTree === node);
viewData.layoutTree = newParent;
}
node.parent.children[nodeIndex] = newParent;
newParent.addChild(node);
}
node.sizeInParent = (1 - sizeOfInsertedNode) * nodeSize;