From cc38223e3f4315f61a50126630170c25ab8b5e1f Mon Sep 17 00:00:00 2001 From: johnwalley Date: Sun, 16 Jan 2022 13:18:28 +0000 Subject: [PATCH] fix: allow changing order of panes --- src/allotment.tsx | 9 +++++---- src/split-view/split-view.ts | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/allotment.tsx b/src/allotment.tsx index b8f99615..ae7401c4 100644 --- a/src/allotment.tsx +++ b/src/allotment.tsx @@ -174,11 +174,11 @@ const Allotment = forwardRef( } }); - for (const key of enter) { - const props = splitViewPropsRef.current.get(key); + for (const enterKey of enter) { + const props = splitViewPropsRef.current.get(enterKey); splitViewRef.current?.addView( - splitViewViewRef.current.get(key)!, + splitViewViewRef.current.get(enterKey)!, { element: document.createElement("div"), minimumSize: props?.minSize ?? minSize, @@ -186,7 +186,8 @@ const Allotment = forwardRef( snap: props?.snap ?? snap, layout: () => {}, }, - Sizing.Distribute + Sizing.Distribute, + keys.findIndex((key) => key === enterKey) ); } diff --git a/src/split-view/split-view.ts b/src/split-view/split-view.ts index 75d1d69e..bee3899f 100644 --- a/src/split-view/split-view.ts +++ b/src/split-view/split-view.ts @@ -415,7 +415,7 @@ export class SplitView extends EventEmitter implements Disposable { ? new VerticalViewItem(container, view, viewSize) : new HorizontalViewItem(container, view, viewSize); - this.viewItems.push(item); + this.viewItems.splice(index, 0, item); if (this.viewItems.length > 1) { const sash = @@ -486,7 +486,7 @@ export class SplitView extends EventEmitter implements Disposable { const sashItem: SashItem = { sash }; - this.sashItems.push(sashItem); + this.sashItems.splice(index - 1, 0, sashItem); } if (!skipLayout) {