Icon: Fix margin being applied twice in the editor - #81292
Icon: Fix margin being applied twice in the editor#81292jorgefilipecosta wants to merge 2 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
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. |
1 similar comment
|
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. |
|
Size Change: +16 B (0%) Total Size: 7.82 MB 📦 View Changed
|
84896c4 to
4c5587c
Compare
4c5587c to
66f48dd
Compare
|
Flaky tests detected in 66f48dd. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/31134465609 should load styles added through enqueue_block_assets in |
Fixes the Icon block applying margin twice in the editor.
The margin block support is serialized to the block wrapper, but in the editor the inner SVG element was also receiving the margin styles, because the full spacing styles were spread onto it. On the front end only padding is applied to the SVG, so a block with a margin looked considerably more spaced out in the editor canvas than on the published page. To fix this we pass only the padding to the spacing styles applied to the inner SVG element, matching the front-end output.
Screenshots
An Icon block with a background color,
24pxpadding and a48pxmargin, placed inside a Group with a contrasting background, so the margin is visible as the purple space around the icon.Before
The margin is applied on both the block wrapper and the inner SVG, so the editor renders
96pxof extra space (2 ×48px) compared to the front end.After
The editor matches the front end.
Testing Instructions
AI usage disclosure: fix and description drafted with AI assistance and reviewed by me.