WordPress / gutenberg

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

Columns block: changing the vertical block spacing also wrongly changes the horizontal block spacing #45277

Open dianeco opened 1 year ago

dianeco commented 1 year ago

Description

Changing the vertical block spacing of the columns block also changes the horizontal block spacing, which isn't the expected behavior. The horizontal block spacing should keep its default value.

Step-by-step reproduction instructions

  1. Using the Twenty Twenty-Three theme, insert two columns by pasting the following code.
<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column {"style":{"spacing":{"padding":{"top":"var:preset|spacing|30","right":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30"}}},"backgroundColor":"primary"} -->
<div class="wp-block-column has-primary-background-color has-background" style="padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:paragraph -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut leo nibh, placerat eget nisi non, sagittis convallis purus.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->

<!-- wp:column {"style":{"spacing":{"padding":{"top":"var:preset|spacing|30","right":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30"}}},"backgroundColor":"primary"} -->
<div class="wp-block-column has-primary-background-color has-background" style="padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:paragraph -->
<p>Morbi in iaculis ligula. Mauris in libero suscipit, pulvinar erat a, rutrum purus.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->

By default, the horizontal spacing is set by the theme.json file with a value of 1.5rem.

01

  1. Select the columns block. In the settings sidebar, change only the vertical block spacing. Inside the editor, observe that the horizontal spacing has changed to 0.5em.
.editor-styles-wrapper .wp-block-columns.wp-container-1 {
    gap: var(--wp--preset--spacing--60) 0.5em;
}

02

  1. On the front end, the horizontal spacing has changed to 2em.
.wp-block-columns.wp-container-1 {
    flex-wrap: nowrap;
    gap: var(--wp--preset--spacing--60) 2em;
}

03

I expect the horizontal spacing to keep the default value (1.5rem for Twenty Twenty-Three).

Screenshots, screen recording, code snippet

No response

Environment info

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

ndiego commented 1 year ago

This issue was reviewed in today's Editor Bug Scrub. We have been able to replicate using the latest versions of Gutenberg and WordPress.

The issue can be "fixed" by manually specifying horizontal spacing in addition the custom vertical spacing, but at @dianeco indicates, you would expect the default theme blockGap value to be used instead of the hardcoded values in the Editor and Frontend.

carolinan commented 1 year ago

Ran into this today, it is still an issue.

tp-cast-ai commented 1 year ago

This is still broken. Even the manual "fix" won't always work. Only a single gap value is generated on the frontend. I'm not sure why the UI is even in the Editor if it's completely broken 🤔

richtabor commented 10 months ago

@carolinan Is this still occurring? I've not noticed it lately.

t-hamano commented 7 months ago

Tested with Gutenberg version 17.6.0, WordPress version 6.4.3, and the TT3 theme. This problem still appears to be unresolved.

On the editor side, the default gap value is 1.5rem:

Screenshot ![image](https://github.com/WordPress/gutenberg/assets/54422211/22f36e4e-10e0-404f-89d9-7f674664b27c)

The same goes for the front end:

Screenshot ![image](https://github.com/WordPress/gutenberg/assets/54422211/ae9b0214-db99-454a-ab5d-7174e3438f9a)

Change the vertical spacing to 4 on the slider. The gap value becomes var(--wp--preset--spacing--60) 0.5em and the horizontal space changes unintentionally.

Screenshot ![image](https://github.com/WordPress/gutenberg/assets/54422211/683e8bd5-cbcf-4ac8-ad76-d13338828c03)

On the front end, the gap value is var(--wp--preset--spacing--60) 2em and the horizontal gap value is different from the default 1.5rem.

Screenshot ![image](https://github.com/WordPress/gutenberg/assets/54422211/da6714a3-ac36-4c58-9c2d-fd344d98e020)