WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.21k forks source link

Group block: border-radius attribute to achieve rounded edges only clips content on bottom but not on top #52559

Open porg opened 1 year ago

porg commented 1 year ago

Description

User Need

Reproduction

  1. Create a group
  2. Nest some blocks into it, Paragraph block, Bullet List block, Image block
  3. Give all of them a visible background-color
  4. Give the group a border-radius of e.g. 16px on all 4 edges (top-left, top-right, bottom-right, bottom-left)

Expected: You get 4 rounded edges. Content of the nested blocks is clipped on all 4 edges.

Actual: Only the bottom-left and bottom-right edge get rounded and clip their content.

Attempted workarounds: Tried with various blocks (Paragraph, Bullet List, Image block, 3rd party Gutenslider block). Also tried themself alone, or wrapped within another group. Did not help. On the top the sharp edges always remained. Content was not clipped.

https://github.com/WordPress/gutenberg/assets/737143/218e5867-cf20-4666-b1ed-5b1ce9e7b9b7

Environment

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

porg commented 1 year ago

Workaround: CSS helper classes

.has-overflow-hidden { overflow: hidden;  }
.has-rounded-edges-30 { overflow: hidden; border-radius: var(--wp--preset--spacing--30); }
.has-rounded-edges-40 { overflow: hidden; border-radius: var(--wp--preset--spacing--30); }
t-hamano commented 1 year ago

@porg

Thanks for submitting the issue.

I think this problem would occur in all orientations, whether above or below. As seen in the CSS helper class you presented, the solution to this problem would be to apply overflow:hidden in the block to which the border-radius is applied. However, it would need to be thoroughly tested to ensure that it does not cut off something unintended.

I would mark this issue as an enhancement, not a bug.

porg commented 1 year ago
  1. It is okay that you changed the type from bug to enhancement.

  2. Thanks for the input what was the exact missing attribute. Updated my above comment to differentiate between the current state of Column (no border-radius UI controls at all, see #41345 ) and Group (just needs overflow:hidden so that the UI option border-radius gets really into effect).