From 2ddf502b160a1baf4de49c632e64de27fb41a570 Mon Sep 17 00:00:00 2001 From: lwih Date: Wed, 24 Apr 2024 12:51:16 +0200 Subject: [PATCH] fix(components): make banner visible again when isClosable or isCollapsible change (rapportnav usecase) --- src/components/Banner/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/Banner/index.tsx b/src/components/Banner/index.tsx index 5ce7b8151..5ba08d263 100644 --- a/src/components/Banner/index.tsx +++ b/src/components/Banner/index.tsx @@ -46,14 +46,22 @@ function Banner({ const [isCollapsing, setIsCollapsing] = useState(false) const [hasCollapsed, setHasCollapsed] = useState(false) + useEffect(() => { + // Reset visibility/height when isCollapsible or isClosable change + setIsHidden(false) + setIsCollapsed(false) + setIsCollapsing(false) + setHasCollapsed(false) + }, [isCollapsible, isClosable]) + const enterHover = (): void => { - if (!isHidden && isCollapsed && !isCollapsing) { + if (isCollapsible && !isHidden && isCollapsed && !isCollapsing) { setIsCollapsed(false) } setIsCollapsing(false) } const leaveHover = (): void => { - if (!isHidden && hasCollapsed) { + if (isCollapsible && !isHidden && hasCollapsed) { setIsCollapsed(true) } }