Skip to content

Commit

Permalink
fix: respect visible prop on initial render
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwalley committed Feb 20, 2022
1 parent 81373a4 commit 5daeeaf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/allotment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const Allotment = forwardRef<AllotmentHandle, AllotmentProps>(
);
}

for (const updateKey of update) {
for (const updateKey of [...enter, ...update]) {
const props = splitViewPropsRef.current.get(updateKey);
const index = keys.findIndex((key) => key === updateKey);

Expand Down
6 changes: 4 additions & 2 deletions stories/allotment.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export const PaneClassName: Story = (args) => {
};

export const Visible: Story<AllotmentProps> = (args) => {
const [visible, setVisible] = useState(true);
const [visible, setVisible] = useState(false);

return (
<div>
Expand All @@ -312,7 +312,9 @@ export const Visible: Story<AllotmentProps> = (args) => {
</div>
);
};
Visible.args = {};
Visible.args = {
defaultSizes: [400, 100],
};

export const OnReset: Story = (args) => {
const ref = useRef<AllotmentHandle>(null!);
Expand Down

2 comments on commit 5daeeaf

@pahen
Copy link
Contributor

@pahen pahen commented on 5daeeaf Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this change broke stuff. I'm not able to use the "visible" prop at all after this change @johnwalley

@pahen
Copy link
Contributor

@pahen pahen commented on 5daeeaf Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to only be a problem when using it with defaultSizes ..

Please sign in to comment.