Opened 3 years ago
Last modified 3 years ago
#54040 new defect (bug)
Changing element text or background color should only affect color
Reported by: | brylie | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.8 |
Component: | Editor | Keywords: | |
Focuses: | css | Cc: |
Description
Page elements get unintended padding when changing background or font color, violating the principle of least astonishment.
In effect, the end-user is expecting that a change to the background color would have only one outcome. Instead, there is a second side-effect where the element gets padding.
Padding is added to many elements via CSS selectors that mostly target ".has-background," such as the following.
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/heading/style.css#L76-L78
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/heading/style-rtl.css#L76-L78
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/list/style.min.css#L1
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/list/style-rtl.min.css#L1
- https://github.com/WordPress/WordPress/blob/270f2011f8ec7265c3f4ddce39c77ef5b496ed1c/wp-content/themes/twentytwentyone/assets/sass/05-blocks/group/_editor.scss#L18-L23
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/list/style-rtl.css#L72-L74
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/list/style.css#L72-L74
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/paragraph/style-rtl.css#L101-L103
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/paragraph/style.css#L101-L103
- https://github.com/WordPress/WordPress/blob/270f2011f8ec7265c3f4ddce39c77ef5b496ed1c/wp-content/themes/twentytwentyone/assets/sass/05-blocks/rss/_editor.scss#L104-L107
- https://github.com/WordPress/WordPress/blob/270f2011f8ec7265c3f4ddce39c77ef5b496ed1c/wp-content/themes/twentytwentyone/assets/sass/05-blocks/rss/_style.scss#L104-L107
- https://github.com/WordPress/WordPress/blob/8a11188d0f5728bc9bbdf331ff9174d45b1768a6/wp-content/themes/twentytwentyone/assets/sass/03-generic/vertical-margins.scss#L159-L161
- https://github.com/WordPress/WordPress/blob/270f2011f8ec7265c3f4ddce39c77ef5b496ed1c/wp-content/themes/twentytwentyone/assets/sass/05-blocks/paragraph/_editor.scss#L4-L6
- https://github.com/WordPress/WordPress/blob/1a7033e75ff6b5911b2b9d34ceee38e80084b85e/wp-content/themes/twentytwentyone/assets/sass/05-blocks/query-loop/_style.scss#L3-L8
- https://github.com/WordPress/WordPress/blob/1a7033e75ff6b5911b2b9d34ceee38e80084b85e/wp-content/themes/twentytwentyone/assets/sass/05-blocks/query-loop/_editor.scss#L3-L7
- https://github.com/WordPress/WordPress/blob/270f2011f8ec7265c3f4ddce39c77ef5b496ed1c/wp-content/themes/twentytwentyone/assets/sass/05-blocks/paragraph/_style.scss#L6-L8
- https://github.com/WordPress/WordPress/blob/0a2b52dfeb4e28e4ff3714899a2890a779c3748f/wp-content/themes/twentytwentyone/assets/sass/05-blocks/latest-posts/_style.scss#L112-L115
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/preformatted/style.css#L75-L77
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/preformatted/style-rtl.css#L75-L77
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/group/editor.css#L83-L86
- https://github.com/WordPress/WordPress/blob/8df663cbfafedd6e594c3df8101e6085dfe18035/wp-includes/blocks/group/editor-rtl.css#L83-L86
- https://github.com/WordPress/WordPress/blob/c3ea09ebb8034be04f42e5aaf5f523cbead7e2a4/wp-includes/blocks/columns/style.css#L85-L87
- https://github.com/WordPress/WordPress/blob/c3ea09ebb8034be04f42e5aaf5f523cbead7e2a4/wp-includes/blocks/columns/style-rtl.css#L85-L87
- https://github.com/WordPress/WordPress/blob/0638de4c60de0d9cf800ca887177b67ba8ad68f0/wp-content/themes/twentynineteen/style-editor.scss#L868-L880
- https://github.com/WordPress/WordPress/blob/270f2011f8ec7265c3f4ddce39c77ef5b496ed1c/wp-content/themes/twentyseventeen/assets/css/editor-blocks.css#L496-L498
Attachments (1)
Change History (8)
#3
@
3 years ago
Well, I'm glad we agree that the styles should be removed :-) I am available to remove some of them, such as those linked above.
#4
@
3 years ago
As an aside, I was confused as to why some of the Gutenberg container blocks had padding while others didn't. And I needed to dig into the code to figure out why.
I don't believe it is ideal for our content editors to debug idiosyncratic layout issues.
This ticket was mentioned in Slack in #core-test by hellofromtonya. View the logs.
3 years ago
#6
@
3 years ago
Steps to reproduce the issue
Env
- WordPress: 5.8
- Browser: Firefox Developer Edition 92.0b9
- OS: macOS Big Sur 11.1
- Localhost: Local and
wp-env
- Theme: Twenty Twenty-One
- Plugins: none
- Scripts: none
Steps to reproduce
- In a new post/page, add a text block (paragraph or heading)
- In the block background color settings, select a color for the background
Test Results
- Notices that there is a padding that is a spacing that is added to the block in the editor
- Notices the spacing being added on the frontend also
- When inspecting the block, notices that a padding is added when the block has the
.has-background
CSS class (https://core.trac.wordpress.org/attachment/ticket/54040/block-with-has-background-class.2.png)
Styling is not subject to that arbitrary principle.
The fact is that adding a background color makes the content look bad when the color stops right at the edge of it. A little padding with
box-sizing: border-box
looks much better.The problem is that the styling should not be done by the editor or individual blocks. The styling should be done by the theme. If you are proposing that those styles are removed, I would agree, but for a different reason.