-
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
Adds current menu class to navigation block #20076
Conversation
Thinking about this PR, if we implement this block in a future |
|
||
$html .= '<li class="' . esc_attr( $css_classes . ( $has_submenu ? ' has-child' : '' ) ) . '"' . $style_attribute . '>' . | ||
$html .= '<li class="' . esc_attr( $css_classes . ( $has_submenu ? ' has-child' : '' ) ) . | ||
( $is_active ? ' current-menu-item' : '' ) . '"' . $style_attribute . '>' . |
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.
To follow the pattern set by other class names, shouldn't it be something like is-current-navigation-link
?
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 think the is-
prefix fits pretty good here, in the same way that is-selected
, etc... does.
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.
yes but all WP menus use this convention of current-menu-item, check wp_nav_menu. There is a whole section of default CSS classes and this is-* convention isn't there.
<< I do agree >> with the is-* convention it is just unclear when we start breaking backwards compat.
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.
The changes made to the Navigation block won't have any effect on existing themes (which don't use blocks at all), so I see no problem with using an is-
class here. But maybe someone else has another opinion?
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.
adding both of them is too much? So, we could guarantee the compatibility with the wp_nav_menu(), and at the same time maybe adding a super basic style for .is-current-navigation-link
?
.is-current-navigation-link {
border: 1px solid red; // ;-)
}
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.
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.
@retrofox That sounds like overkill to me. It should be entirely up to the theme to determine if the current navigation link recieves special styles or not.
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.
Fair enough. Just bringing here the idea that I could be handled in both ways. Through the theme and/or a Navigation option.
Could we add a very simple default style? could it be too intrusive? |
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.
One small bug to be addressed, but looks good apart from that 😄
081c57a
to
37e20eb
Compare
Size Change: -863 B (0%) Total Size: 856 kB
ℹ️ View Unchanged
|
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.
Looks good!
This seems to be breaking the experimental Site Editor for me. I'm still not sure if it's related to the template content that I had before. |
Description
Closes #19993
Closes #19858
This PR adds two new updates to the server side rendering of the
Navigation
block:How has this been tested?
2.1 Add a custom CSS class to one of the links
Types of changes
Updated the server side rendering of the
Navigation
block to output the custom CSS class of eachNavigationLink
and to check for the current post ID.