-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Home link block: Add 'current-menu-item' #51478
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carolinan One question below. Also, checks are in a weird state. Needs refresh?
Flaky tests detected in 4eb1a23. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5517782322
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how we missed this when initially adding the current-menu-item
classes...
Good catch @carolinan, thank you for working on this!
Approving this one, it's good to merge 👍
Thank you both. This is so great to see! 👏 |
What?
Adds the CSS class 'current-menu-item' to the home link block.
Testing instructions were updated June 26.
Closes #34770
Why?
Adding the class makes the block easier to style. The class is already used in the page list block and the navigation link block, and this change makes it easier to style the current menu items consistently.
How?
Adds the CSS class, conditionally, to the
<li>
item in the block's index.php file.Testing Instructions
Add a navigation block to a site-wide header template part. The important thing is that the menu item can be tested on the correct page to trigger the condition and add the CSS class.
Inside the navigation block, insert the Home link block.
View the homepage on the front of the website.
Confirm that the Home link block has the CSS class
current-menu-item
on the li element:<li class="wp-block-navigation-item current-menu-item wp-block-home-link">
Open any link on the site that is not the homepage, and confirm that the Home menu item no longer has the
current-menu-item
class.There are two edge cases, and that is when the user adds the assigned "posts page" and or the homepage from the Reading settings to the navigation block, besides the home link block. In this case, the class name as well as the aria-current attribute, will be duplicated.
I think this needs to be considered a user error, adding the same link more than once.