Skip to content

Commit

Permalink
fix: allow changing order of panes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwalley committed Jan 16, 2022
1 parent b2b7598 commit cc38223
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/allotment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,20 @@ const Allotment = forwardRef<AllotmentHandle, AllotmentProps>(
}
});

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,
maximumSize: props?.maxSize ?? maxSize,
snap: props?.snap ?? snap,
layout: () => {},
},
Sizing.Distribute
Sizing.Distribute,
keys.findIndex((key) => key === enterKey)
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/split-view/split-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit cc38223

Please sign in to comment.