Open gillespieza opened 6 years ago
Hey @gillespieza,
Thanks for reporting this. I'll take a look either tonight or tomorrow and see where I need to fix this :)
Hey, sorry for delays. I am not able to reproduce this output. I'm getting:
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1707" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1707 nav-item"><div class="dropdown-divider" title="a divider">a divider</div></li>
Are you using the latest version of the walker? Are my settings the same as yours?
I wasn't using the latest version. My apologies. Once I updated, the issue went away.
No apologies necessary, glad you got it fixed :)
I am using the latest version 4.1.0 (just redownloaded again from https://github.com/wp-bootstrap/wp-bootstrap-navwalker/blob/master/class-wp-bootstrap-navwalker.php) and have the same problem.
I embedded the menu with the following code:
<?php wp_nav_menu(array(
'theme_location' => 'primary',
'depth' => 0,
'container' => 'div',
'container_class'=>'collapse navbar-collapse',
'container_id'=> 'nav-primary',
'menu_class'=>'navbar-nav ml-auto',
'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
'walker' => new WP_Bootstrap_Navwalker(),
)); ?>
Adding a sub-menu item with
results in the following item
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-5434" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-5434 nav-item"><div class="dropdown-divider" title="-" class="dropdown-item dropdown-divider">–</div></li>
As you can see the class is inserted twice
Hey @lanort,
Sorry you are having issues. I can see in your markup that it is duplicated but in my test install it is not and I am not able to recreate this with the latest version from master
branch.
The markup that I end up with is:
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1727" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1727 nav-item"><div class="dropdown-divider" title="–">–</div></li>
Is there anything else at all you think might be relevant to help me recreate this issue and fix it?
Thanks @pattonwebz.
Is this the actual source code or already the interpreted one? I think in my browser also only the first class counts and the second one is ignored (this would end up the same as in your result).
However I will check that on another website of mine tomorrow, just to make sure I or another plugin did not mess up anything.
You make a good point, this is likely generated markup. I will check actual source as soon as I am able.
I reopened the ticket since you confirmed this is still an issue. I might have spotted a potential fix for it earlier when scanning the code in my test install.
Let me know what you see in your end, I'll be sure to check proper source on my end as well.
Just tried the current version on another website and it had the same result: <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1651" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1651 nav-item"><div class="dropdown-divider" title="-" class="dropdown-item dropdown-divider">–</div></li>
You can see it here http://neu.derzahn.at
The dropdown-divider was inserted with this data:
The interpreted code has the double class already stripped (but the source code of course still has the double class):
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1651" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1651 nav-item"><div class="dropdown-divider" title="-">–</div></li>
Note: this is still a bug.
The class dropdown-divider
is added here
https://github.com/wp-bootstrap/wp-bootstrap-navwalker/blob/c856e941c4209581f8b90a31cc33350c758b3cfb/class-wp-bootstrap-navwalker.php#L502-L504
and here
https://github.com/wp-bootstrap/wp-bootstrap-navwalker/blob/c856e941c4209581f8b90a31cc33350c758b3cfb/class-wp-bootstrap-navwalker.php#L556-L558
This is also the case for dropdown-header
and dropdown-item-text
.
When I run my rendered HTML source code through a validator, it shows that items with the class "dropdown-divider" are getting the class added twice.
Here is an example of my output:
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-6731" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6731 nav-item"><div class="dropdown-divider" title="----" class="dropdown-item dropdown-divider">/</div></li>
The last div is getting
class="dropdown-divider"
andclass="dropdown-item dropdown-divider"