#53220 closed defect (bug) (fixed)
Twenty Twenty-One: Refactor or remove navigation item padding CSS
Reported by: | Joen | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 6.2 | Priority: | normal |
Severity: | normal | Version: | 5.6 |
Component: | Bundled Theme | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
Twenty Twenty One has a CSS custom property that targets navigation menu items:
.wp-block-navigation .wp-block-navigation-link .wp-block-navigation-link__content { padding: var(--primary-nav--padding); }
There are a few problems with that. First off, it prevents the block from inheriting padding values set by the Global Styles system. See https://github.com/WordPress/gutenberg/issues/31784
Secondly, it overrides new default behavior for the navigation block, which is to have zero padding for menu items unless a background color is set. This behavior is created to enable navigation menus that align with headings and site titles that don't have any padding. See https://github.com/WordPress/gutenberg/pull/30805.
Finally, the rule targets only custom menu items, not menu items generated by the dynamic Page List block.
Recommended solution: either remove the rule entirely and rely on default values, or leverage the global styles system to apply padding.
For reference, here is the CSS the will be applying padding to the navigation menu item in the future:
.wp-block-navigation .wp-block-pages-list__item a, .wp-block-navigation .wp-block-navigation-link a { padding: 0; }
Attachments (3)
Change History (25)
This ticket was mentioned in PR #1723 on WordPress/wordpress-develop by jasmussen.
3 years ago
#2
- Keywords has-patch added
This PR aims to fix obsolete navigation block styles in the TwentyTwentyOne theme.
Trac ticket: https://core.trac.wordpress.org/ticket/53220
#3
@
3 years ago
I took a stab at a patch for this in https://github.com/WordPress/wordpress-develop/pull/1723. There are a few issues around the padding, much of it related to how heavily TT1 styles the navigation block, which has then drifted due to how much the block has evolved over the past year. In this gallery there are a few screenshots of how there's a top/bottom margin on every block, there's a separate padding value attached to the wrong element, and incorrect spacing between items due to the change to using gap: https://cloudup.com/c5HjvVORdzJ
I haven't been working on TT1 initially, so there's likely a lot of context for the original styles that I'm unaware of. So I would appreciate a good test.
#4
@
2 years ago
For Gutenberg 11.5, the CSS class names in the navigation block were updated. The padding in the theme styles is not applied on WordPress version 5.9 or 6.0.
There are a few things I think that we need to consider:
-Twenty Twenty-one is possibly the last classic theme (Twenty Twenty-Three has not been announced yet), so we should try to solve these types of issues.
-WordPress 5.6 (reported version) - 5.8 does not support the navigation block without Gutenberg. And Gutenberg has a minimum required WordPress version which is 5.8. This minimum required version will keep increasing.
-Generally I would prefer to not remove CSS variables as they may be used by child themes.
But because of the above reasons, I think removing them would only have a low negative impact, and a positive impact for users who are on older versions of WordPress and Gutenberg.
We may need to discuss if we should limit the loading of some CSS to older versions of WordPress.
#5
@
20 months ago
@Joen I have tested the navigation block with 6.2 alpha and the appearance tools theme support.
Enabling this theme support as suggested in #56487 enables block gap for the navigation block.
I did not find any apparent spacing issues, I believe it is working well.
With that in mind, how would you prefer to proceed with this CSS changes?
#6
@
20 months ago
With that in mind, how would you prefer to proceed with this CSS changes?
Seems like we can apply the patch and go from there? Forgive me if I'm misunderstanding the question.
#7
@
20 months ago
- Keywords commit added
- Milestone changed from Awaiting Review to 6.2
Then let's move this into the 6.2 milestone to remove the redundant CSS. From what I can tell from my testing, the PR does not need to be refreshed.
#9
@
20 months ago
- Owner set to audrasjb
- Status changed from new to accepted
Ok the changeset looks good on my side too 👍
Self assigning for commit consideration.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
20 months ago
#12
@
20 months ago
Reopening as it seems like [55088] modified some version controlled files.
Revert incoming.
This ticket was mentioned in PR #3862 on WordPress/wordpress-develop by @SergeyBiryukov.
20 months ago
#17
- Keywords needs-refresh removed
Trac ticket: https://core.trac.wordpress.org/ticket/53220
#18
@
20 months ago
- Keywords changes-requested removed
53220.diff or PR 3862 should be a clean refresh of the previous PR without unrelated formatting changes.
Note: When rebuilding the theme's CSS files on Windows, I still got unrelated formatting changes similar to the ones in the previous PR, but rebuilding on Ubuntu via WSL did the trick. This could use some further investigation as to why building on Windows gives a different result, but the tests appear to pass with the new PR.
#19
@
20 months ago
I tested the PR and it works fine on my side, thank you for refreshing the PR Sergey!
@audrasjb commented on PR #3862:
20 months ago
#22
Committed in https://core.trac.wordpress.org/changeset/55101, thanks again Sergey!
Looks like this line has been included since the theme was first moved to SVN. Updating the
version
.