-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Cover block: Only apply overflow:clip when a cover block has a border and a border radius #73789
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
base: trunk
Are you sure you want to change the base?
Conversation
… and a border radius
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
| } | ||
| } | ||
|
|
||
| &.has-border-radius.has-border { |
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.
We should probably note reasons why we apply conditionally here. Doens't have to mention navigation but can mention elements that need to expand beyond the bounds of the cover block.
|
Size Change: +379 B (+0.01%) Total Size: 2.58 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 251e8e8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/19963447607
|
| html.has-modal-open { | ||
| overflow: hidden; | ||
| } | ||
|
|
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.
Let's ditch this whitespace.
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 tested adding a border radius without a border and the border radius doesn't work without the overflow being set.
I was able to make this work by using contain: paint but that also seems to clip the overflow again.
Unless I'm wrong then we'll need to gate the overflow to border-radius on its own as well 😢
Update: or could we also apply the border-radius to the children that cause the overflow, namely:
- the
position: absoluteimgthat is used for background image - the
spanthat is used in the same way
If they have matching radius does that work and avoid the need for overflow hidden at all?
What?
Adds has-border and has-border-radius CSS classes to the Cover block when border or border-radius styles are applied.
Why?
The Cover block needs
overflow: clipapplied when it has a border radius and border set, so that the background doesn't bleed around the border. However,overflow: clipprevents navigation submenus from appearing outside the block (see #45353)If we only apply
overflow: clipwhen a border radius and border are set on the block, then we'll limit the problem in #45353 to only impact this very specific case, which makes it much more of an edge case.To only apply
overflow: clipwhen the block has a border and border-radius, we need to add classes to the block in these cases.The Cover block supports border and border-radius styling through block supports, but wasn't outputting semantic CSS classes to indicate when these styles were present. The CSS file already contained styles targeting .has-border-radius.has-border (line 224 in style.scss), but these classes were never being added to the block markup, making those styles unreachable.
Adding these classes:
Partially fixes #45353
How?
- Extended the function to detect border width/style properties and add has-border class
- Added detection for border-radius properties and add has-border-radius class
- Handles both unified properties (style.border.width) and split borders (style.border.top.width, etc.)
- Handles both unified radius and individual corner radii
- Imported and called getBorderClassesAndStyles utility
- Applied the returned border classes to the cover block wrapper
- Created a deprecation for blocks saved without the border classes
- Ensures existing Cover blocks with borders automatically migrate to include the new classes
- Merged duplicate .wp-block-cover selectors to resolve linting error
- Consolidated the has-border-radius.has-border styles into the main selector block
Testing Instructions
Testing new blocks:
Testing existing blocks (deprecation):
Testing split borders:
Testing the navigation block
Screenshots or screencast