How to close the Navbar when a NavLi is clicked on mobile? #1085
-
I have a regular navbar like this:
When the user clicks one of the So the first question is: how do you close the NavUl on mobile? What I have tried: I tried calling the toggle function like this:
It works on mobile, but then on desktop, the So, if this is the expected way to close the NavUl, is there a way to close it without triggering all these animations/re-rendering for desktop? Let me rephrase the situation: when using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
did you figure this out? I did the following as a work around: let hideNavMenu = true;
const onNavHamburgerClick = (toggleFn: () => void) => {
toggleFn();
hideNavMenu = false;
};
const onNavLinkClick = (toggleFn: () => void) => {
hideNavMenu = true;
}; <Navbar let:toggle">
...
<NavHamburger onClick={() => onNavHamburgerClick(toggle)} />
...
<NavUl
hidden={hideNavMenu}
on:click={() => onNavLinkClick(toggle)}
> |
Beta Was this translation helpful? Give feedback.
did you figure this out? I did the following as a work around: