Skip to content

Commit

Permalink
chore: ensure dropdowns close when the pullout closes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwisecodes committed Aug 29, 2024
1 parent 555fb9f commit 024d25f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ const DropDownSection = ({
value,
documentContainerRef,
userHasCancelledAutoScroll,
showLessonMobile,
}: {
objectKey: string;
sectionRefs: Record<string, React.MutableRefObject<HTMLDivElement | null>>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value: any;
documentContainerRef: React.MutableRefObject<HTMLDivElement | null>;
userHasCancelledAutoScroll: boolean;
showLessonMobile: boolean;
}) => {
const sectionRef = useRef(null);
if (sectionRefs) sectionRefs[objectKey] = sectionRef;
Expand All @@ -33,6 +35,12 @@ const DropDownSection = ({
const [prevValue, setPrevValue] = useState<Record<string, unknown>>({});
const [sectionHasFired, setSectionHasFired] = useState(false);

useEffect(() => {
if (!showLessonMobile) {
setIsOpen(false);
}
}, [showLessonMobile]);

useEffect(() => {
if (value === null || value === undefined || !value) {
setStatus("empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export const LessonPlanDisplay = ({
value={value}
userHasCancelledAutoScroll={userHasCancelledAutoScroll}
documentContainerRef={documentContainerRef}
showLessonMobile={showLessonMobile}
/>
);
}
Expand Down

0 comments on commit 024d25f

Please sign in to comment.