Repository navigation
Navigation: keep Global Styles custom CSS off inner list containers - #85366
Conversation
Navigation's inner list also carries the wp-block-navigation class, so block-level Additional CSS from Global Styles applied twice on the front end. Give the custom CSS its own selector that excludes the list.
🤖 PR meta 🤖🎉 PropsIf 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. Updated as activity occurs, without notifying anyone named here. Add the ⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Regression: updating a specific option will only change its value and will not corrupt others in
|
There was a problem hiding this comment.
🟢 Approval recommended
The focused selector change uses existing CSS-generation support and has no identified blocking issues; tests were not run.
No open issues 🎉
What changed in this PR
This follow-up extends Navigation’s wrapper-only Additional CSS behavior to Global Styles, preventing duplicate borders and padding on inner lists.
Changes:
- Adds a custom CSS selector that excludes inner list containers while supporting both
<nav>and<div>wrappers. - Adds a PHP regression test and updates the block documentation and changelog.
| File | Description |
|---|---|
| phpunit/blocks/render-block-navigation-test.php | Tests the generated Global Styles CSS selector. |
| packages/block-library/src/navigation/README.md | Documents the custom CSS selector. |
| packages/block-library/src/navigation/block.json | Restricts Global Styles Additional CSS to Navigation wrappers. |
| packages/block-library/CHANGELOG.md | Records the Navigation styling fix. |
Review effort: Balanced
…85366) Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
|
I just cherry-picked this PR to the wp/7.2 branch to get it included in the next release: c6b641f |

What?
Follow-up to #84881. Apply a Navigation block's Global Styles Additional CSS to its outer wrapper only.
Props to @andrewserong for catching it!
Why?
The inner
<ul>also carries thewp-block-navigationclass (#62690), so:root :where(.wp-block-navigation)matches both elements, and borders and padding appear twice on the front end. Raised in the #84881 review.How?
Give Navigation a custom CSS selector in
block.json(selectors.css, added in #75799):.wp-block-navigation:not(.wp-block-navigation__container). It uses:not()rather thannav.because a Navigation nested in an overlay renders as a<div>. Block style variation custom CSS uses the same selector.As with #84881, Global Styles rules such as
& > lino longer reach the list on the front end. They never applied in the editor.Testing Instructions
border: 1px solid pink; padding: 20px;and save.<ul>has neither.Use of AI Tools
Claude Code investigated the cause and wrote the change and test.