Skip to content

How to close the Navbar when a NavLi is clicked on mobile? #1085

Answered by danclaroni
planetaska asked this question in Q&A
Discussion options

You must be logged in to vote

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)}
        >

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@planetaska
Comment options

@planetaska
Comment options

Answer selected by planetaska
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants