Skip to content

Commit

Permalink
Improved panel size validation in PanelGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Jun 10, 2023
1 parent 110d1d7 commit 65c64e7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/react-resizable-panels/src/PanelGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,16 @@ function PanelGroupWithForwardedRef({
}
});

if (
totalDefaultSize > 100 ||
(panelsWithNullDefaultSize === 0 && totalDefaultSize !== 100)
if (totalDefaultSize > 100) {
throw new Error(`Default panel sizes cannot exceed 100%`);
} else if (
panelsArray.length > 1 &&
panelsWithNullDefaultSize === 0 &&
totalDefaultSize !== 100
) {
throw new Error(`Invalid default sizes specified for panels`);
} else if (totalMinSize > 100) {
throw new Error(`Invalid minimum sizes specified for panels`);
throw new Error(`Minimum panel sizes cannot exceed 100%`);
}

setSizes(
Expand Down

0 comments on commit 65c64e7

Please sign in to comment.