gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Change Background color of paragraph block has different effect in styles and page-editor

Open burnuser opened this issue 4 years ago • 4 comments

Description

Test with 5.9-RC3 and Twenty Twenty-Two: Asigning a background color in Styles => Blocks => Paragraph works Asigning a background color in Pages => Edit => Paragraph works But the result in the created webpage is different (see attached screenshot)

as reported in Core Trac: https://core.trac.wordpress.org/ticket/54865

Different layout for background color

Step-by-step reproduction instructions

see description above

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

Yes

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

Yes

burnuser avatar Jan 21 '22 15:01 burnuser

This is still present in WP6.3.

When a background is added in the page editor the paragraph receives additional style classes, including .has-background.

This then applies the style:

p.has-background {
    padding: 1.25em 2.375em;
}

But when adding the background through global styles - no additional classes are added to the element.

jordesign avatar Aug 18 '23 04:08 jordesign

Here i want to confirm one point that how we should resolve this issue , we should match behaviour with Global styling that is padding is not added when background color is applied or we should remove addition of padding when background color is applied from Inspector Controls.

cc : @mikachan

dpmehta avatar Apr 13 '26 06:04 dpmehta

Thanks for the ping! I think my preference here would be to ensure the has-background class, which adds the padding, is added to any element that has a background colour. So it looks like we need to add this class when the background is applied via Global Styles.

mikachan avatar Apr 14 '26 09:04 mikachan

My preference here would be to stop adding has-background class and instead apply a non 0 padding on the UI when the user picks a background on a block that has no padding. That way things stay simple and consistent:

  • Background applies just background
  • Padding applies just padding.
  • The "smart behavior" is just a UX affordance you can reset.

youknowriad avatar Aug 08 '26 11:08 youknowriad