diff --git a/src/DonorDashboards/resources/js/app/components/mobile-menu/index.js b/src/DonorDashboards/resources/js/app/components/mobile-menu/index.js index 7a17884623..ebe4b5fa2a 100644 --- a/src/DonorDashboards/resources/js/app/components/mobile-menu/index.js +++ b/src/DonorDashboards/resources/js/app/components/mobile-menu/index.js @@ -8,11 +8,11 @@ import './style.scss'; const MobileMenu = ({children}) => { const [isOpen, setIsOpen] = useState(false); - const contentRef = useRef(null); + const toggleRef = useRef(null); useEffect(() => { const handleClick = (evt) => { - if (contentRef.current && !contentRef.current.contains(evt.target)) { + if (toggleRef.current && !toggleRef.current.contains(evt.target)) { setIsOpen(false); } }; @@ -26,7 +26,7 @@ const MobileMenu = ({children}) => { document.removeEventListener('click', handleClick); } }; - }, [isOpen, contentRef]); + }, [isOpen, toggleRef]); const location = useLocation(); const tabsSelector = useSelector((state) => state.tabs); @@ -39,16 +39,19 @@ const MobileMenu = ({children}) => {