From cd2eae13116af91af00846e212452287cfb7c607 Mon Sep 17 00:00:00 2001 From: china-bin <2986528628@qq.com> Date: Sun, 5 Dec 2021 20:59:55 +0800 Subject: [PATCH] fix: defaultSizes needs to be used (#77) --- src/allotment.tsx | 6 +++--- stories/allotment.stories.tsx | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/allotment.tsx b/src/allotment.tsx index 5507cc5f..d3483ca3 100644 --- a/src/allotment.tsx +++ b/src/allotment.tsx @@ -118,10 +118,10 @@ const Allotment = forwardRef( const options: SplitViewOptions = { orientation: vertical ? Orientation.Vertical : Orientation.Horizontal, ...(initializeSizes && - sizes && { + defaultSizes && { descriptor: { - size: sizes.reduce((a, b) => a + b, 0), - views: sizes.map((size, index) => ({ + size: defaultSizes.reduce((a, b) => a + b, 0), + views: defaultSizes.map((size, index) => ({ container: [...splitViewViewRef.current.values()][index], size: size, view: { diff --git a/stories/allotment.stories.tsx b/stories/allotment.stories.tsx index 0ce3ac99..efeb440c 100644 --- a/stories/allotment.stories.tsx +++ b/stories/allotment.stories.tsx @@ -208,3 +208,15 @@ export const Reset: Story = (args) => { ); }; Reset.args = {}; + +export const DefaultSize: Story = () => { + return ( +
+ +
div1
+
div2
+
+
+ ); +}; +DefaultSize.args = {};