diff --git a/packages/react-components/src/components/OnboardingChecklist/OnboardingChecklist.stories.tsx b/packages/react-components/src/components/OnboardingChecklist/OnboardingChecklist.stories.tsx index 1f7ea3898..ca356f538 100644 --- a/packages/react-components/src/components/OnboardingChecklist/OnboardingChecklist.stories.tsx +++ b/packages/react-components/src/components/OnboardingChecklist/OnboardingChecklist.stories.tsx @@ -166,3 +166,45 @@ export const Default = (): React.ReactElement => { /> ); }; + +export const ShortBanner = (): React.ReactElement => { + const [activeItem, setActiveItem] = React.useState('1'); + const [checkedIds, setCheckedIds] = React.useState([]); + const [, setIsCompleted] = React.useState(false); + + const handlePrimaryClick = (id: string) => { + setCheckedIds((prev) => [...prev, id]); + setActiveItem((prev) => (parseInt(prev) + 1).toString()); + + if (checkedIds.length === 4) { + setIsCompleted(true); + } + }; + + const handleSecondaryClick = (id: string) => setActiveItem(id); + + return ( + + ), + }} + /> + ); +}; diff --git a/packages/react-components/src/components/OnboardingChecklist/OnboardingChecklist.tsx b/packages/react-components/src/components/OnboardingChecklist/OnboardingChecklist.tsx index fefcd3cc3..d063f211b 100644 --- a/packages/react-components/src/components/OnboardingChecklist/OnboardingChecklist.tsx +++ b/packages/react-components/src/components/OnboardingChecklist/OnboardingChecklist.tsx @@ -34,6 +34,7 @@ export const OnboardingChecklist: React.FC = ({ >(undefined); const containerRef = React.useRef(null); const COMPLETE_CONTAINER_HEIGHT = completionMessageData.height || 96; + const HEIGHT_BUFFER = 50; // Adjust?? const handleButtonClick = () => { setIsOpen((prev) => !prev); @@ -43,7 +44,7 @@ export const OnboardingChecklist: React.FC = ({ const delay = completionMessageData.delay || 1500; const container = containerRef.current; - if (isCompleted && container) { + if (isCompleted && container && !isChecklistCompleted) { const currentHeight = container.offsetHeight; setCurrentContainerHeight(currentHeight); @@ -56,7 +57,16 @@ export const OnboardingChecklist: React.FC = ({ clearTimeout(timeoutId); }; } - }, [isCompleted]); + }, [isCompleted, isChecklistCompleted]); + + React.useEffect(() => { + if (containerRef.current) { + const newHeight = isOpen + ? containerRef.current.scrollHeight + HEIGHT_BUFFER + : COMPLETE_CONTAINER_HEIGHT; + setCurrentContainerHeight(newHeight); + } + }, [isOpen, isChecklistCompleted]); return (
= ({ className )} style={{ - height: - !isChecklistCompleted || isOpen - ? currentContainerHeight - : COMPLETE_CONTAINER_HEIGHT, + height: currentContainerHeight, }} > {isOpen && (