#39758 closed defect (bug) (fixed)
menu-item-home does not get class current-menu-item (not consistent with live page)
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.8 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | Customize | Keywords: | needs-testing has-patch |
Focuses: | Cc: |
Description
When inside of the customizer, and the navigation menu has a home menu item, and the user is on the home page, that menu item will not get tagged with the class current-menu-item
nor current_page_item
inside of <li>
.
This is not consistent with the live page of the navigation menu. The live page does include both current-menu-item
and current_page_item
when being on the home page.
Home menu item on live page:
<li id="menu-item-2" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-2"><a href="http://example.com/">Home</a></li>
Home menu item in customizer:
<li id="menu-item-2" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-2"><a href="http://example.com/">Home</a></li>
As you can see, current-menu-item current_page_item
are missing in the customizer.
Attachments (3)
Change History (24)
#2
@
8 years ago
- Keywords has-patch reporter-feedback added
- Milestone changed from Awaiting Review to 4.8
- Owner set to adamsilverstein
- Status changed from new to assigned
- Version changed from 4.7.2 to 4.7
In 39758.diff:
Nav Menus: Fix an issue with menu classes in the customizer.
Remove query vars when comparing menu urls with current url to determine correct menu item classes.
In the customizer, menu items now contain a changeset uuid
as part of their url string, eg http://wpdev.localhost/?customize_changeset_uuid=ddc1fa2e-e347-4042-8f1c-f5ac470839e0&customize_theme=twentyseventeen&customize_messenger_channel=preview-0
. The code in nav-menu-template.php
wasn't working because these urls didn't match the comparison urls without the query vars, breaking applied classes in several cases. This patch strips the query var off the url before entering the comparison block and fixes the case raised on the ticket.
cc: @westonruter
@Liddika can you please give this patch a test and test if it resolves the issue you were seeing? Thanks.
#3
@
8 years ago
- Keywords needs-testing added; reporter-feedback removed
- Milestone changed from 4.8 to 4.7.3
Good catch! Seems that this should be milestoned for 4.7.3
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
#5
@
8 years ago
@Liddika any results from your testing of the 39758.diff patch and whether it resolves the issue you were seeing?
This ticket was mentioned in Slack in #core by swissspidy. View the logs.
8 years ago
#8
@
8 years ago
- Keywords needs-patch added; has-patch removed
The fix is breaking functionality in the specific situation when the permalinks are set to the default 'plain' setting.
Testing variables
- p=1 > set as static home page
- p=2 > normal page
- permalink structure: 'plain'
- have a 'Home' menu item
- have the normal page as menu item
When a page other than the Home page is loaded, the Home link is also receiving the 'current-menu-item' and 'current_page_item' classes.
Whenever the permalink structure is including a '?' the relative root cannot be determined because the entire permalink match should be taken into consideration to have a certain request identification.
This ticket was mentioned in Slack in #core by swissspidy. View the logs.
8 years ago
#10
@
8 years ago
- Keywords has-patch added; needs-patch removed
Hi @westonruter, @jipmoors ,
I have added a patch which will check if that is customize page then it will replace the relative root variable.
I have also checked the patch in breaking functionality provided by @jipmoors. It is working perfectly fine.
This ticket was mentioned in Slack in #core-customize by priyankabehera. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by priyankabehera. View the logs.
8 years ago
#13
@
8 years ago
- Keywords needs-refresh added
Hi @priyankabehera155 thanks for your patch!
This seems like a good solution, thanks also for checking that it also resolves @jipmoors issue (and @jipmoors, thanks for catching that!). Can you please refresh the patch with tabs instead of spaces and also maybe add a comment line above the conditional explaining why the code is there? Thanks!
#14
@
8 years ago
- Keywords needs-refresh removed
Hi @adamsilverstein,
Thank you for your points.
I have added a short comment which describes the code and the coding standard tab instead of space. Thanks!
@Liddika Thanks for the bug report.
I tried to reproduce this issue and I actually see the
current-menu-item
class added to the homepage menu item when I have the homepage set to a specific page. I don't see thecurrent_page_item
class in the customizer however.Can you please try to reproduce with a bundled theme, and also provide some additional details about your settings - do you have the homepage set to a static page or your latest posts? What does your menu item link to exactly, is it a custom link?
Here are some screenshots of what I see -
Front end:

Customizer:
