Skip to content

Commit

Permalink
fix: improve the timing when to check empty of panels (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortalYoung authored Jul 13, 2021
1 parent 088edd2 commit 5ef6a82
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/collapse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function Collapse(props: ICollapseProps) {
}, []);

React.useLayoutEffect(() => {
// It's necessary to check panel's empty before calculate every panel
filterData.forEach((panel) => {
const isActive = activePanelKeys.includes(panel.id);
let isEmpty = true;
Expand All @@ -103,6 +104,9 @@ export function Collapse(props: ICollapseProps) {
isEmpty = !contentDom?.hasChildNodes();
}
panel._isEmpty = isEmpty;
});

filterData.forEach((panel) => {
const [height, top] = calcPosition(
activePanelKeys,
panel,
Expand Down

0 comments on commit 5ef6a82

Please sign in to comment.