-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Correctly apply current-menu-ancestor class in Nav block #67169
Conversation
I'm guessing this class isn't applied in the Editor because there is no concept of this there right? |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
that sounds about right, it would be hard to map |
@@ -222,7 +222,7 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) { | |||
|
|||
if ( strpos( $inner_blocks_html, 'current-menu-item' ) ) { | |||
$tag_processor = new WP_HTML_Tag_Processor( $html ); | |||
while ( $tag_processor->next_tag( array( 'class_name' => 'wp-block-navigation-item__content' ) ) ) { |
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 wonder how many websites are targeting the "wrong" selector...
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.
Not sure. class
is not a first party API though but as we know we need to acknowledge the impact on existing Themes.
How has this been handled in the past? It's not like we can throw an error if someone is using that class.
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 we just consider the risk and go with it. I can't remember when we've done this recently. Maybe a dev note?
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.
@WordPress/block-themers anyone remember an instance of class changing like this?
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.
See #67134
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.
If I read this right that the .wp-block-navigation-item__content
class will be removed by this change, it looks like it's used by a considerable number of themes and a few plugins too.
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.
@mrwweb it looks like that class is only used to iterate there and to determine where to place the current-menu-ancestor
class. So, this specific change doesn't mean that the wp-block-navigation-item__content
class will be removed.
anyone remember an instance of class changing like this?
I don't.
I'm ok tentatively approving this if we get some more feedback from themers. If this only affect block themes, I've done a search on a dump I have of block themes in the themes repo and I don't see many themes that would be affected by this change |
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.
This is testing well for me! I really like that it brings parity with how things work in classic themes.
My fear is also that we don't know how many sites could be targeting the wrong selector. It looks like there's only a handful of themes doing this in the repository, though.
Yeah, I haven't been able to find much more than that myself, I think this is a low risk change. |
Ugh, sorry I misclicked there :( |
@bph Would it be worth dropping this in the Outreach channel in Slack for feedback? |
Absolutely! You can also ping the @WordPress/outreach group here on GitHub. |
I'll leave this open a few more days to allow for further feedback. Otherwise I think we just need an approving review (with the caveat for the approver that it's agreed that it's not 100% possible to know if this will have some negative side effects). |
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 problem is valid, the code makes sense.
I approved, although I do wonder about it a bit in terms of removing the class from the anchor, what is wrong with:
|
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.
Given how early in the release we are and how little the impact seems to be when inspecting the code for themes in the directory, I think this is good to land as is to get it out and get feedback
I don't think we should double up. It could be very confusing. Either move it or leave it "as is". |
I'm going to merge this one as soon as I can get the PHP unit tests to run correctly. |
@getdave I re-ran the failed tests, and they’re all passing now 🚀 |
…Press#67169 Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: carolinan <poena@git.wordpress.org> Co-authored-by: mrwweb <mrwweb@git.wordpress.org> Co-authored-by: juanfra <juanfra@git.wordpress.org> Co-authored-by: draganescu <andraganescu@git.wordpress.org> Co-authored-by: bph <bph@git.wordpress.org> Co-authored-by: jordesign <jordesign@git.wordpress.org> Co-authored-by: webmandesign <webmandesign@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: carolinan <poena@git.wordpress.org> Co-authored-by: mrwweb <mrwweb@git.wordpress.org> Co-authored-by: juanfra <juanfra@git.wordpress.org> Co-authored-by: draganescu <andraganescu@git.wordpress.org> Co-authored-by: bph <bph@git.wordpress.org> Co-authored-by: jordesign <jordesign@git.wordpress.org> Co-authored-by: webmandesign <webmandesign@git.wordpress.org>
What?
Applies the
current-menu-ancestor
class to the<li>
not the<a>
Closes #50069
Why?
Consistency with
current-menu-item
which is applied to the<li>
.How?
Applies the
current-menu-ancestor
class to the<li>
not the<a>
Testing Instructions
You should be able to test this via Playground using the following link
https://playground.wordpress.net/?gutenberg-pr=67169
Note you can install any publicly available Theme for testing using the format:
On your WordPress test site you can then...
li
nota
.Testing Instructions for Keyboard
Screenshots or screencast