wp-bootstrap / wp-bootstrap-navwalker

A custom WordPress nav walker class to fully implement the Twitter Bootstrap 4.0+ navigation style (v3-branch available for Bootstrap 3) in a custom theme using the WordPress built in menu manager.
https://wp-bootstrap.github.io/wp-bootstrap-navwalker/
GNU General Public License v3.0
3.37k stars 1.94k forks source link

Navwalker dropdown doesn't remain open on click #517

Closed stfschn closed 3 years ago

stfschn commented 3 years ago

Hello there,

I've encountered a problem which I haven't had before with navwalker.

Wordpress-Version: 5.7.1 Navwalker-Version: current Bootstrap-Version: 4.6

What I expected:

The dropdown menu should work just as usual. Using the following code to include the walker:

<nav class="navbar navbar-expand-md fixed-top navbar-dark bg-dark  justify-content-center" id="navimenu" role="navigation">
    <a class="navbar-brand mx-2" href="<?php echo home_url(); ?>">
        <img height="80px" src="<?php echo get_site_url(); ?>/wp-content/themes/child-theme/logo.jpg"> 
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-controls="bs-example-navbar-collapse-1" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <?php
    wp_nav_menu( array(
        'menu'            => 'primary',
        'theme_location'  => 'menu-1',
        'depth'           => 1,
        'container'       => 'div',
        'container_class' => 'collapse navbar-collapse justify-content-stretch',
        'container_id'    => 'bs-example-navbar-collapse-1',
        'menu_class'      => 'nav navbar-nav ml-auto',
        'fallback_cb'     => 'WP_Bootstrap_Navwalker::fallback',
        'walker'          => new WP_Bootstrap_Navwalker()
    ) );
    ?>
</nav>

What happened instead:

The dropdown menu opens onClick, however it does close immediately. Bootstrap and jQuery seem to be included in the regular wordpress way. Is there a way to keep the dropdown open?

Kemoshousha309 commented 3 years ago

I have the same problem :(

josephsizar commented 3 years ago

the same as wheel

josephsizar commented 3 years ago

the problem here is the walker i think i will use Jquery to let dropdown working wheel!

IanDelMar commented 3 years ago

@stfschn, use 'depth' => 2. That should solve the issue.

@josephsizar , @Kemoshousha309 please check whether you also used 'depth' => 1 and try using 'depth' => 2 instead.

This is documented in the usage section of the readme.

image

However, specifying 'depth' => 1 breaks the menu in the current version of the walker. Though no dropdowns are allowed the first level menu item still behaves like a dropdown. The walker even displays the caret. This will be fixed in v5 of the walker.

IanDelMar commented 3 years ago

Closing this due to lack of feedback.