Skip to content

Commit

Permalink
fix: unsync local and props state
Browse files Browse the repository at this point in the history
  • Loading branch information
gjulivan committed Jul 19, 2024
1 parent 7939aec commit 11b9522
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,17 @@ export function AccordionGroup(props: AccordionGroupProps): ReactElement | null
}
} else if (props.collapsed !== renderCollapsed && (!animateContent || !props.visible)) {
setRenderCollapsed(props.collapsed);
} else if (props.collapsed === renderCollapsed) {
// if state and props looses their sync due to "complete transition" not being triggered
// make sure it is sync back in.
if (
(renderCollapsed && rootRef.current?.classList.contains("widget-accordion-group-expanding")) ||
(!renderCollapsed && rootRef.current?.classList.contains("widget-accordion-group-collapsing"))
) {
completeTransitioning();
}
}
}, [props.collapsed, props.visible, renderCollapsed, animateContent]);
}, [props.collapsed, props.visible, renderCollapsed, animateContent, completeTransitioning]);

useEffect(() => {
if (renderCollapsed !== previousRenderCollapsed.current) {
Expand Down

0 comments on commit 11b9522

Please sign in to comment.