Repository navigation
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 |
|
|
||
| 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.
I wonder how many websites are targeting the "wrong" selector...
There was a problem hiding this comment.
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.
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.
@WordPress/block-themers anyone remember an instance of class changing like this?
There was a problem hiding this comment.
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.
@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 |
juanfra
left a comment
There was a problem hiding this comment.
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). |
draganescu
left a comment
There was a problem hiding this comment.
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:
|
MaggieCabrera
left a comment
There was a problem hiding this comment.
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>
|
I apologize for commenting on a merged PR and for drifting slightly off-topic, but I would like to highlight an IMO important point:
and
Thank you for taking the time to review the publicly available block-theme repository; that analysis is valuable. Nevertheless, the data set in the .org directory covers only a fraction of the ecosystem. Many, perhaps most, production themes are private, commercially licensed. This is especially true in enterprise environments. Those installations rarely surface in public scans, yet even minor markup changes can impose significant maintenance costs. In light of this, I believe the block editor should adopt a consistent policy for changes that relocate or rename markup or CSS hooks. Ideally, new behavior would be introduced in parallel with the legacy behavior for e.g., a full release cycle, accompanied by a developer and/or an announcement in the Field Guide. This grace period gives theme authors adequate time to adapt. Afterward, the legacy path can be removed. For this specific change, adding Thank you! 🙇🏽♂️ |
What?
Applies the
current-menu-ancestorclass to the<li>not the<a>Closes #50069
Why?
Consistency with
current-menu-itemwhich is applied to the<li>.How?
Applies the
current-menu-ancestorclass 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...
linota.Testing Instructions for Keyboard
Screenshots or screencast