-
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
Generate element classnames from element-specific data #59533
Conversation
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @nitamorais. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/block-supports/elements.php |
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.
Thanks for reviewing, folks! Might be good to release 17.8.1 with this fix. |
Yes, that's a great idea 👍 |
Bit slow but this tests well for me and resolves the issue outlined in #59462. We probably also need to update core so that the classname generation function doesn't appear to accept a full block object. |
Unlinked contributors: nitamorais. Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: huubl <huubl@git.wordpress.org>
I just cherry-picked this PR to the release/17.8 branch to get it included in the next release: d9c88be |
@tellthemachines we still have a problem with the element link styles. The latest approach means we generate the same class for two blocks with the same style set. With nesting, this can break the correct inheritance of styles. Screen.Recording.2024-03-04.at.10.41.48.am.mp4 |
The When the two blocks generate the same class name, the same CSS might be generated but there is only a single entry in the style engine store. It retains its original place in the order such that any subsequent blocks that had the matching style data won't have their own unique class and styles meaning they could be overridden incorrectly. I think we still need a way to make these classes unique but predictable. |
Hm I suspect that's due to deduping of rules in the style engine. I guess an alternative approach would be to use |
I had similar thoughts. We'd probably need to go back to more than just the element styles to avoid the conflict in class name all the same. |
I have a draft PR up (#59535) that aims to avoid the latest issue with element classes and styles. |
I'm assuming this is not a 6.5 issue but just want to confirm. |
I originally reported #51082 where the link color style selector was wrong. I just confirmed via WordPress Playground that this PR fixes this issue. Thank you 🙏 |
Yes, I believe this isn't required for 6.5. While the underlying issue was reported last year (#51082), it was recently exposed via updates to the layout block support that are for 6.6. |
What?
Fixes #59462.
Classname generation for block-specific element (e.g. link, heading) styles was dependent on the block array being identical between
pre_render_block
andrender_block
filters. That can't be assured, because between those two filters, therender_block_data
filter also runs and the block array can be modified within it.This PR updates the element classname hash generation to use only the
style.elements
array instead of the full block, because that is less likely to change between filters.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast