mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-14 13:22:37 +00:00
refactor(app): choose split group sizes at the call site
This commit is contained in:
@@ -872,19 +872,6 @@ function SplitGroupChild({
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sizes from a divider drag are kept per group id, apart from the layout tree. A group keeps its
|
||||
* id when panes are added or removed, so the dragged sizes only apply while they still have one
|
||||
* entry per child; otherwise the dividers past the end of the list could not move.
|
||||
*/
|
||||
function resolveGroupSizes(
|
||||
layoutSizes: number[],
|
||||
draggedSizes: number[] | undefined,
|
||||
childCount: number,
|
||||
): number[] {
|
||||
return draggedSizes?.length === childCount ? draggedSizes : layoutSizes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flex grow per child, renormalized so the visible ones always sum to 1.
|
||||
*
|
||||
@@ -981,11 +968,12 @@ function SplitNodeView({
|
||||
groupId ? state.splitSizesByWorkspace[workspaceKey]?.[groupId] : undefined,
|
||||
);
|
||||
const groupChildren = node.kind === "group" ? node.group.children : EMPTY_SPLIT_NODES;
|
||||
const groupSizes = resolveGroupSizes(
|
||||
node.kind === "group" ? node.group.sizes : EMPTY_SPLIT_SIZES,
|
||||
storedGroupSizes,
|
||||
groupChildren.length,
|
||||
);
|
||||
// Dragged sizes live per group id, apart from the layout tree, and a group keeps its id when
|
||||
// panes are added or removed. They only apply while they still have one entry per child;
|
||||
// otherwise the dividers past the end of the list could not move.
|
||||
const layoutGroupSizes = node.kind === "group" ? node.group.sizes : EMPTY_SPLIT_SIZES;
|
||||
const groupSizes =
|
||||
storedGroupSizes?.length === groupChildren.length ? storedGroupSizes : layoutGroupSizes;
|
||||
const visibleFlex = useMemo(
|
||||
() => resolveVisibleGroupFlex(groupChildren, groupSizes, maximizedPaneId),
|
||||
[groupChildren, groupSizes, maximizedPaneId],
|
||||
|
||||
Reference in New Issue
Block a user