Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

fix: mobile menu doesn't close on click #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions starter/components/elements/mobile-nav-menu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useEffect } from "react"
import { useRouter } from "next/router"
import PropTypes from "prop-types"
import { MdClose, MdChevronRight } from "react-icons/md"
import { mediaPropTypes, linkPropTypes, buttonLinkPropTypes } from "utils/types"
Expand All @@ -10,6 +12,12 @@ import CustomLink from "./custom-link"
const MobileNavMenu = ({ navbar, closeSelf }) => {
// Prevent window scroll while mobile nav menu is open
useLockBodyScroll()

const router = useRouter()

useEffect(() => {
closeSelf()
}, [router.asPath])

return (
<div className="w-screen h-screen fixed top-0 left-0 overflow-y-scroll bg-white z-10 pb-6">
Expand Down