Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Columns: Avoid using CSS variables for block gap styles #37436

Merged
merged 6 commits into from
Jan 5, 2022

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Dec 16, 2021

Description

An experimental PR to make the Columns block gap behave should we remove the CSS var from the block styles. See:

In short, we're forcing a flex layout via __experimentalLayout and related properties. The rest is allowing flex gap to do its thing.

This branch

Kapture 2021-12-16 at 14 59 57

Trunk

Kapture 2021-12-16 at 15 03 24

Changes included

  • Opt in to the Layout block support for flex styling, hides the layout controls in the inspector
  • Update CSS to remove references to the block gap CSS variable
  • Update "tablet" viewport rules to allow the columns to grow/shrink to smooth over the removal of the hard-coded 50% width at that breakpoint (the 50% rule had to be removed as we can't calculate the appropriate gap without a CSS variable. See: Columns: Avoid using CSS variables for block gap styles #37436 (comment))
  • Add a couple of !important CSS rules to smooth over differences between the Layout support's styles and the current styles for the Columns block

How has this been tested?

  • Insert a columns block.
  • Try out columns blocks with a variety of column numbers and widths (e.g. be sure to test non-standard widths like (25%, 50%, 25%) and hard-coded widths like 200px.
  • Test the per-column vertical alignment options.
  • Test that de-selecting the stack on mobile setting still allows forcing columns all onto the one row
  • Try adjusting the block gap at the parent Columns block level
  • Test that the columns render correctly at desktop, tablet, and mobile viewports
  • Test with a variety of patterns and themes

Types of changes

Bug fix with a potential breaking change for tablet viewport widths.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@github-actions
Copy link

github-actions bot commented Dec 16, 2021

Size Change: -601 B (0%)

Total Size: 1.13 MB

Filename Size Change
build/block-library/blocks/columns/editor-rtl.css 108 B -102 B (-49%) 🎉
build/block-library/blocks/columns/editor.css 108 B -100 B (-48%) 🎉
build/block-library/blocks/columns/style-rtl.css 406 B -96 B (-19%) 👏
build/block-library/blocks/columns/style.css 406 B -95 B (-19%) 👏
build/block-library/editor-rtl.css 10 kB -46 B (0%)
build/block-library/editor.css 10 kB -44 B (0%)
build/block-library/index.min.js 165 kB -7 B (0%)
build/block-library/style-rtl.css 10.8 kB -55 B (-1%)
build/block-library/style.css 10.8 kB -56 B (-1%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 960 B
build/admin-manifest/index.min.js 1.1 kB
build/annotations/index.min.js 2.75 kB
build/api-fetch/index.min.js 2.21 kB
build/autop/index.min.js 2.12 kB
build/blob/index.min.js 459 B
build/block-directory/index.min.js 6.28 kB
build/block-directory/style-rtl.css 1.01 kB
build/block-directory/style.css 1.01 kB
build/block-editor/default-editor-styles-rtl.css 378 B
build/block-editor/default-editor-styles.css 378 B
build/block-editor/index.min.js 140 kB
build/block-editor/style-rtl.css 14.6 kB
build/block-editor/style.css 14.6 kB
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 65 B
build/block-library/blocks/archives/style.css 65 B
build/block-library/blocks/audio/editor-rtl.css 58 B
build/block-library/blocks/audio/editor.css 58 B
build/block-library/blocks/audio/style-rtl.css 111 B
build/block-library/blocks/audio/style.css 111 B
build/block-library/blocks/audio/theme-rtl.css 125 B
build/block-library/blocks/audio/theme.css 125 B
build/block-library/blocks/block/editor-rtl.css 161 B
build/block-library/blocks/block/editor.css 161 B
build/block-library/blocks/button/editor-rtl.css 470 B
build/block-library/blocks/button/editor.css 470 B
build/block-library/blocks/button/style-rtl.css 560 B
build/block-library/blocks/button/style.css 560 B
build/block-library/blocks/buttons/editor-rtl.css 292 B
build/block-library/blocks/buttons/editor.css 292 B
build/block-library/blocks/buttons/style-rtl.css 275 B
build/block-library/blocks/buttons/style.css 275 B
build/block-library/blocks/calendar/style-rtl.css 207 B
build/block-library/blocks/calendar/style.css 207 B
build/block-library/blocks/categories/editor-rtl.css 84 B
build/block-library/blocks/categories/editor.css 83 B
build/block-library/blocks/categories/style-rtl.css 79 B
build/block-library/blocks/categories/style.css 79 B
build/block-library/blocks/code/style-rtl.css 90 B
build/block-library/blocks/code/style.css 90 B
build/block-library/blocks/code/theme-rtl.css 134 B
build/block-library/blocks/code/theme.css 134 B
build/block-library/blocks/comment-template/style-rtl.css 127 B
build/block-library/blocks/comment-template/style.css 127 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/cover/editor-rtl.css 546 B
build/block-library/blocks/cover/editor.css 547 B
build/block-library/blocks/cover/style-rtl.css 1.22 kB
build/block-library/blocks/cover/style.css 1.22 kB
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 417 B
build/block-library/blocks/embed/style.css 417 B
build/block-library/blocks/embed/theme-rtl.css 124 B
build/block-library/blocks/embed/theme.css 124 B
build/block-library/blocks/file/editor-rtl.css 300 B
build/block-library/blocks/file/editor.css 300 B
build/block-library/blocks/file/style-rtl.css 255 B
build/block-library/blocks/file/style.css 255 B
build/block-library/blocks/file/view.min.js 322 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB
build/block-library/blocks/freeform/editor.css 2.44 kB
build/block-library/blocks/gallery/editor-rtl.css 966 B
build/block-library/blocks/gallery/editor.css 970 B
build/block-library/blocks/gallery/style-rtl.css 1.6 kB
build/block-library/blocks/gallery/style.css 1.6 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 159 B
build/block-library/blocks/group/editor.css 159 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 114 B
build/block-library/blocks/heading/style.css 114 B
build/block-library/blocks/html/editor-rtl.css 332 B
build/block-library/blocks/html/editor.css 333 B
build/block-library/blocks/image/editor-rtl.css 810 B
build/block-library/blocks/image/editor.css 809 B
build/block-library/blocks/image/style-rtl.css 507 B
build/block-library/blocks/image/style.css 511 B
build/block-library/blocks/image/theme-rtl.css 124 B
build/block-library/blocks/image/theme.css 124 B
build/block-library/blocks/latest-comments/style-rtl.css 284 B
build/block-library/blocks/latest-comments/style.css 284 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B
build/block-library/blocks/latest-posts/editor.css 137 B
build/block-library/blocks/latest-posts/style-rtl.css 528 B
build/block-library/blocks/latest-posts/style.css 527 B
build/block-library/blocks/list/style-rtl.css 94 B
build/block-library/blocks/list/style.css 94 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 493 B
build/block-library/blocks/media-text/style.css 490 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 649 B
build/block-library/blocks/navigation-link/editor.css 650 B
build/block-library/blocks/navigation-link/style-rtl.css 94 B
build/block-library/blocks/navigation-link/style.css 94 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation-submenu/view.min.js 343 B
build/block-library/blocks/navigation/editor-rtl.css 1.93 kB
build/block-library/blocks/navigation/editor.css 1.94 kB
build/block-library/blocks/navigation/style-rtl.css 1.8 kB
build/block-library/blocks/navigation/style.css 1.79 kB
build/block-library/blocks/navigation/view.min.js 2.82 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 377 B
build/block-library/blocks/page-list/editor.css 377 B
build/block-library/blocks/page-list/style-rtl.css 172 B
build/block-library/blocks/page-list/style.css 172 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B
build/block-library/blocks/paragraph/editor.css 157 B
build/block-library/blocks/paragraph/style-rtl.css 273 B
build/block-library/blocks/paragraph/style.css 273 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/style-rtl.css 446 B
build/block-library/blocks/post-comments-form/style.css 446 B
build/block-library/blocks/post-comments/style-rtl.css 509 B
build/block-library/blocks/post-comments/style.css 509 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B
build/block-library/blocks/post-excerpt/editor.css 73 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B
build/block-library/blocks/post-excerpt/style.css 69 B
build/block-library/blocks/post-featured-image/editor-rtl.css 721 B
build/block-library/blocks/post-featured-image/editor.css 721 B
build/block-library/blocks/post-featured-image/style-rtl.css 153 B
build/block-library/blocks/post-featured-image/style.css 153 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 391 B
build/block-library/blocks/post-template/style.css 392 B
build/block-library/blocks/post-terms/style-rtl.css 73 B
build/block-library/blocks/post-terms/style.css 73 B
build/block-library/blocks/post-title/style-rtl.css 80 B
build/block-library/blocks/post-title/style.css 80 B
build/block-library/blocks/preformatted/style-rtl.css 103 B
build/block-library/blocks/preformatted/style.css 103 B
build/block-library/blocks/pullquote/editor-rtl.css 198 B
build/block-library/blocks/pullquote/editor.css 198 B
build/block-library/blocks/pullquote/style-rtl.css 389 B
build/block-library/blocks/pullquote/style.css 388 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 234 B
build/block-library/blocks/query-pagination/style.css 231 B
build/block-library/blocks/query/editor-rtl.css 131 B
build/block-library/blocks/query/editor.css 132 B
build/block-library/blocks/quote/style-rtl.css 187 B
build/block-library/blocks/quote/style.css 187 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/rss/editor-rtl.css 202 B
build/block-library/blocks/rss/editor.css 204 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 165 B
build/block-library/blocks/search/editor.css 165 B
build/block-library/blocks/search/style-rtl.css 397 B
build/block-library/blocks/search/style.css 398 B
build/block-library/blocks/search/theme-rtl.css 64 B
build/block-library/blocks/search/theme.css 64 B
build/block-library/blocks/separator/editor-rtl.css 99 B
build/block-library/blocks/separator/editor.css 99 B
build/block-library/blocks/separator/style-rtl.css 245 B
build/block-library/blocks/separator/style.css 245 B
build/block-library/blocks/separator/theme-rtl.css 172 B
build/block-library/blocks/separator/theme.css 172 B
build/block-library/blocks/shortcode/editor-rtl.css 474 B
build/block-library/blocks/shortcode/editor.css 474 B
build/block-library/blocks/site-logo/editor-rtl.css 744 B
build/block-library/blocks/site-logo/editor.css 744 B
build/block-library/blocks/site-logo/style-rtl.css 181 B
build/block-library/blocks/site-logo/style.css 181 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 84 B
build/block-library/blocks/site-title/editor.css 84 B
build/block-library/blocks/social-link/editor-rtl.css 177 B
build/block-library/blocks/social-link/editor.css 177 B
build/block-library/blocks/social-links/editor-rtl.css 670 B
build/block-library/blocks/social-links/editor.css 669 B
build/block-library/blocks/social-links/style-rtl.css 1.32 kB
build/block-library/blocks/social-links/style.css 1.32 kB
build/block-library/blocks/spacer/editor-rtl.css 332 B
build/block-library/blocks/spacer/editor.css 332 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 471 B
build/block-library/blocks/table/editor.css 472 B
build/block-library/blocks/table/style-rtl.css 481 B
build/block-library/blocks/table/style.css 481 B
build/block-library/blocks/table/theme-rtl.css 188 B
build/block-library/blocks/table/theme.css 188 B
build/block-library/blocks/tag-cloud/style-rtl.css 146 B
build/block-library/blocks/tag-cloud/style.css 146 B
build/block-library/blocks/template-part/editor-rtl.css 560 B
build/block-library/blocks/template-part/editor.css 559 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 87 B
build/block-library/blocks/verse/style.css 87 B
build/block-library/blocks/video/editor-rtl.css 571 B
build/block-library/blocks/video/editor.css 572 B
build/block-library/blocks/video/style-rtl.css 173 B
build/block-library/blocks/video/style.css 173 B
build/block-library/blocks/video/theme-rtl.css 124 B
build/block-library/blocks/video/theme.css 124 B
build/block-library/common-rtl.css 910 B
build/block-library/common.css 908 B
build/block-library/reset-rtl.css 474 B
build/block-library/reset.css 474 B
build/block-library/theme-rtl.css 675 B
build/block-library/theme.css 679 B
build/block-serialization-default-parser/index.min.js 1.09 kB
build/block-serialization-spec-parser/index.min.js 2.79 kB
build/blocks/index.min.js 46.3 kB
build/components/index.min.js 215 kB
build/components/style-rtl.css 15.5 kB
build/components/style.css 15.5 kB
build/compose/index.min.js 11.2 kB
build/core-data/index.min.js 13.3 kB
build/customize-widgets/index.min.js 11.4 kB
build/customize-widgets/style-rtl.css 1.5 kB
build/customize-widgets/style.css 1.49 kB
build/data-controls/index.min.js 631 B
build/data/index.min.js 7.49 kB
build/date/index.min.js 31.9 kB
build/deprecated/index.min.js 485 B
build/dom-ready/index.min.js 304 B
build/dom/index.min.js 4.5 kB
build/edit-navigation/index.min.js 16 kB
build/edit-navigation/style-rtl.css 3.76 kB
build/edit-navigation/style.css 3.76 kB
build/edit-post/classic-rtl.css 492 B
build/edit-post/classic.css 494 B
build/edit-post/index.min.js 29.5 kB
build/edit-post/style-rtl.css 7.16 kB
build/edit-post/style.css 7.16 kB
build/edit-site/index.min.js 36.2 kB
build/edit-site/style-rtl.css 6.63 kB
build/edit-site/style.css 6.62 kB
build/edit-widgets/index.min.js 16.5 kB
build/edit-widgets/style-rtl.css 4.17 kB
build/edit-widgets/style.css 4.18 kB
build/editor/index.min.js 37.9 kB
build/editor/style-rtl.css 3.75 kB
build/editor/style.css 3.74 kB
build/element/index.min.js 3.29 kB
build/escape-html/index.min.js 517 B
build/format-library/index.min.js 6.58 kB
build/format-library/style-rtl.css 571 B
build/format-library/style.css 571 B
build/hooks/index.min.js 1.63 kB
build/html-entities/index.min.js 424 B
build/i18n/index.min.js 3.71 kB
build/is-shallow-equal/index.min.js 501 B
build/keyboard-shortcuts/index.min.js 1.8 kB
build/keycodes/index.min.js 1.39 kB
build/list-reusable-blocks/index.min.js 1.72 kB
build/list-reusable-blocks/style-rtl.css 838 B
build/list-reusable-blocks/style.css 838 B
build/media-utils/index.min.js 2.92 kB
build/notices/index.min.js 925 B
build/nux/index.min.js 2.08 kB
build/nux/style-rtl.css 747 B
build/nux/style.css 743 B
build/plugins/index.min.js 1.84 kB
build/primitives/index.min.js 924 B
build/priority-queue/index.min.js 582 B
build/react-i18n/index.min.js 671 B
build/react-refresh-entry/index.min.js 8.44 kB
build/react-refresh-runtime/index.min.js 7.31 kB
build/redux-routine/index.min.js 2.65 kB
build/reusable-blocks/index.min.js 2.22 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 11 kB
build/server-side-render/index.min.js 1.57 kB
build/shortcode/index.min.js 1.49 kB
build/token-list/index.min.js 639 B
build/url/index.min.js 1.9 kB
build/viewport/index.min.js 1.05 kB
build/warning/index.min.js 248 B
build/widgets/index.min.js 7.15 kB
build/widgets/style-rtl.css 1.16 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.04 kB

compressed-size-action

@ramonjd ramonjd self-assigned this Dec 17, 2021
@ramonjd
Copy link
Member Author

ramonjd commented Dec 17, 2021

Not sure if I captured your idea correctly here @youknowriad

I've made a start on removing the CSS var for the Columns block and things appear to work okay so far.

I won't be around for the next two or so weeks, so feel free to destroy this PR if it's not relevant.

cc @andrewserong

@youknowriad
Copy link
Contributor

This captures my idea yes, I kind of expected we'd be able to remove more styles form the block buy maybe there's some special cases for this block that we need to account for (responsiveness...)

I guess we should test this properly and see if everything still works as expected for the columns block (responsiveness, column widths, column count...)

@jasmussen
Copy link
Contributor

I'm partially AFK today, so I can only give some high level thoughts, hopefully they are useful.

  • Longer term I'd love to see us retire across all blocks any "stack on mobile" buttons we have in favor of intrinsic behaviors. But I guess that toggle still needs to work here.
  • Same with the number of columns on the existing "tablet" breakpoint, it's a little arbitrary and ultimately might work better as an intrinsic behavior, for example by defining a minimum column width and letting the system handle the rest. But if we remove that tablet-breakpoint behavior here, we'll need to test any patterns that use columns, and see that they work reasonably well.
  • Moving the columns towards the "native" flex seems like a good step regardless of the other changes. I understand this will let us still control the per-block blockgap from theme.json, is that correct?

It is probably a good idea to move forward with this one if it's necessary for #37360 to land. But it really could use good testing across existing patterns or designs that use columns.

@andrewserong
Copy link
Contributor

Thanks for taking a look @jasmussen! While Ramon isn't around, I thought I'd see if I can help progress this PR 🤞

Longer term I'd love to see us retire across all blocks any "stack on mobile" buttons we have in favor of intrinsic behaviors. But I guess that toggle still needs to work here.

Yes, for the moment we still need it to account for the use case of columns that don't wrap, so I think at this stage our objective is to try to keep close to parity of existing functionality.

Same with the number of columns on the existing "tablet" breakpoint, it's a little arbitrary and ultimately might work better as an intrinsic behavior, for example by defining a minimum column width and letting the system handle the rest.

Totally. I also like the points made in #37252 and in @aristath's exploration into minimum column width in #33330. For our purposes here, there was an issue with trying to keep the existing "tablet" breakpoint CSS as-is — it turns out that the flex-basis value of 50% needed to use a calc() with the block gap CSS variable in order to be able to keep the two columns on the same row when using wrap. Since our objective in this PR is to remove the use of the CSS variable, I've tried the following:

In the "tablet" breakpoint, set flex-grow and flex-shrink to 1 so that we effectively let the columns and their flex-basis determine the best fit within the container. I'm hoping that something in this direction will get us closer to removing the hard-coded 50% columns, while still allowing the columns to collapse elegantly enough when they can. In the following example, with a 25%, 50%, 25% set of columns, the tablet break point preserves something of the ratio, while still stretching to fill the container. In my testing the flex-grow also means that if any of the columns contains bigger content (e.g. full width images) then the columns stretch to the full width of the container, which seems pleasing to me (or at least IMO, a little better than the forced 50% width columns).

Desktop Tablet Mobile
image image image

This will need more testing, of course.

But it really could use good testing across existing patterns or designs that use columns.

Very much this! I'm curious to see how this fares with real world content. If anyone can think of a better approach for the "tablet" breakpoint at this stage, let me know!

I've also added in a default align-items setting to fix the vertical alignment of columns. This can later be refactored to use more of the Layout support, but to keep the change in this PR smaller it seemed like a pragmatic way to fix it.

@andrewserong andrewserong added [Block] Columns Affects the Columns Block [Type] Bug An existing feature does not function as intended labels Dec 21, 2021
@andrewserong andrewserong marked this pull request as ready for review December 21, 2021 05:44
@andrewserong
Copy link
Contributor

I've just switched this PR out of draft. I think it's ready for review and more feedback, but it could use a lot of testing with different patterns / themes, etc to see whether or not the change is disruptive, or if it needs further refining.

@jasmussen
Copy link
Contributor

Thanks for all the thought. Just to be sure I'm reading you clearly, this PR is meant to remove the tablet view for now, right? Because that's what I'm seeing in practice as well. This PR skips it:

3 cols to 1 col

Trunk still has the tablet step:

3 cols to 2 then 1

To be clear, I personally think that's acceptable if we can test sufficiently any existing patterns that might rely on the tablet breakpoint. Also because this effectively fixes #37252, CC: @scruffian and @MaggieCabrera.

For the longer term discussion, it would be really nice if we could find some way to have the columns be equal width, as the arbitrary widths aren't great. Anything we can do here, even if it needs moving towards grid, might be worth it. Was this helpful?

@andrewserong
Copy link
Contributor

Was this helpful?

It sure was, thanks @jasmussen!

Just to be sure I'm reading you clearly, this PR is meant to remove the tablet view for now, right? Because that's what I'm seeing in practice as well.

Yes, in practice we're effectively removing the tablet view, but still allowing wrap at that breakpoint if the content requires it, to hopefully smooth over that viewport width. 🤞 We'll find out in testing with real content whether or not the CSS at that viewport meets out needs. @scruffian and @MaggieCabrera if either of you get time to test this PR with the patterns/themes you're working on, we're very happy for feedback on how to best handle things at that viewport width.

After tomorrow, I'll be AFK, too. Feel free to pick this up if anyone wants to try to get this PR in sooner, otherwise Ramon or I will be able to look at it again early in the near year.

@jasmussen
Copy link
Contributor

Thanks for the clarification! The wrapping on the tablet breakpoint could be a challenge, I imagine that's what's causing the arbitrary width columns in your GIF. As this gets more testing, we might just want to turn that off as well, remove the entire tablet behavior cleanly, then revisit when we can.

@scruffian
Copy link
Contributor

I added a commit which removes the difference between the tablet and mobile behaviour - now the columns stack on tablet too. I also tested with two themes that use columns. Here are the differences:

Stewart:
Before:
Screenshot 2021-12-22 at 08 48 33

After:
Screenshot 2021-12-22 at 09 02 47

Remote:
Before:
Screenshot 2021-12-22 at 09 22 57

After:
Screenshot 2021-12-22 at 09 27 15

IMO this is an improvement, but I am concerned about people who expect the current layout on tablet which will now break...

@MaggieCabrera
Copy link
Contributor

IMO this is an improvement, but I am concerned about people who expect the current layout on tablet which will now break...

I think both behaviors are desirable in different contexts.

I agree with @jasmussen here:

As this gets more testing, we might just want to turn that off as well, remove the entire tablet behavior cleanly, then revisit when we can.

I think it's best that we remove the tablet styles that so far themes would have to override and let themes add it if they need it while we look for a better way of handling this kind of situation.

@jasmussen
Copy link
Contributor

The price of removing the break is we need to thoroughly test any patterns, including older ones, to see if results are mostly acceptable.

@andrewserong
Copy link
Contributor

Thanks everyone (and @scruffian for removing the tablet break point!), I agree, I think that's a better path forward. I'm wrapping up for the year shortly, so I'll leave this PR for everyone else to test (and feel free to merge if it winds up looking viable, of course). Happy to help test / follow up again in the new year.

@ramonjd
Copy link
Member Author

ramonjd commented Jan 4, 2022

Thanks for testing so thoroughly @stacimc

So far everything looks reasonable to me, except that patterns with overlapping columns (Overlapping images and text, for example) have some odd spacing on TT1-blocks:

This looks like a theme-specific phenomenon.

It seems as if TT1 is applying the top and left offset for a tablet-like breakpoint (min-width 652px)

.is-style-twentytwentyone-columns-overlap .wp-block-column:nth-child(2n) {
    margin-left: calc(-2 * var(--wp--custom--spacing--horizontal));
    margin-top: calc(2.5 * var(--wp--custom--spacing--horizontal));
    z-index: 2;
}

Also the columns seem to collapse in Two columns of text with offset heading on Twenty Twenty, so the


overlaps the paragraph:

Looks like this is also very theme-specific. TwentyTwenty places a few negative top margins on Columns Blocks at various breakpoints, and when a wide or full alignment is active.

This one (min-width 700px) appears to be related to the effects we're seeing

.wp-block-columns.alignwide + .wp-block-columns.alignwide,
.wp-block-columns.alignfull + .wp-block-columns.alignfull {
    margin-top: -6rem;
}

Given the specificity to the theme, and the unique effect that they're aiming for I wouldn't catalogue them as blockers for this PR.

I don't see these effects on these patterns at the same breakpoint when changing theme for example.

Twenty Twenty Twenty Twenty Two
Screen Shot 2022-01-04 at 1 19 43 pm Screen Shot 2022-01-04 at 1 19 33 pm

I'd rely on @scruffian's advice, but seeing as they're very specific to the themes, perhaps we could address them in the themes themselves?

@ramonjd
Copy link
Member Author

ramonjd commented Jan 4, 2022

@youknowriad 👋

We've made some final changes and have been testing this PR today.

Aside from some theme-specific issues, things are looking pretty good in my opinion, whatever that's worth. I've followed @stacimc's test plans.

There are probably, as usual, some unknown unknowns, but I haven't managed to come across any blaring sirens in my testing.

If you get time, it would be great to get your opinion on whether it's okay to go ahead and, more importantly, backport this one.

@aaronrobertshaw aaronrobertshaw self-requested a review January 4, 2022 05:30
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 👍

This is testing pretty well for me. Overall my impression is that the spacing of columns is improved in a few themes without any major breakage. I did encounter the theme-specific issues others have already noted.

  • Try adjusting the block gap at the parent Columns block level

I have one small issue/question. Should this be opting into the blockGap support for the Columns block? The GIF in the PR description along with the quoted test instruction suggest it should be.

If we are, would we be removing the margin block support or keeping both despite the overlap?


✅ Tried columns blocks with varying numbers of columns, widths and stacked on/off
✅ Tested all the per-column vertical alignments
✅ Confirmed responsive behaviours for tablet and mobile breakpoints
✅ Tried adjusting block gap at columns block level (after tweaking block.json to opt-in)
✅ Tested with various themes and patterns

Test themes:

  • TwentyTwentyTwo
  • TwentyTwentyOne
  • TT1 Blocks
  • TwentyTwenty
  • TwentyTwenty Blocks
  • TwentyNineteen
  • Hever

Test patterns:

  • Three columns of text
  • Three columns with images and text
  • Pricing table
  • Two columns of text and title
  • Two columns of text with offset heading
  • Overlapping images
  • Overlapping images and text

@ramonjd
Copy link
Member Author

ramonjd commented Jan 4, 2022

Thanks for the thorough testing @aaronrobertshaw

I have one small issue/question. Should this be opting into the blockGap support for the Columns block? The GIF in the PR description along with the quoted test instruction suggest it should be.

Looks like blockGap support was deactivated as part of removing the block gap style CSS variable in Avoid using CSS variables for block gap styles #37360 in this commit.

I didn't get around to updating the test description today. Will get onto that now. Sorry for the confusion!

If we are, would we be removing the margin block support or keeping both despite the overlap?

That's a great question. In my limited view, I don't see why we couldn't keep the axial top/bottom margin. It seems to be uniform in it's application.

Jan-04-2022 19-00-34

Others might have a different opinion.

Let's see if @youknowriad thinks this PR is okay to approve and backport this PR today 🎉

@aaronrobertshaw
Copy link
Contributor

That's a great question. In my limited view, I don't see why we couldn't keep the axial top/bottom margin. It seems to be uniform in it's application.

My concern was for mobile/tablet and once the columns start stacking. Would we not end up with both the block gap and the margin being applied? As a result of Flex not having collapsing margins.

@youknowriad
Copy link
Contributor

This PR looks good to me. Should we bring back the blockGap support as well (it's removed on trunk)

@ramonjd
Copy link
Member Author

ramonjd commented Jan 4, 2022

Should we bring back the blockGap support as well (it's removed on trunk)

I've been testing this. It looks pretty stable and work as expected (that is, no real unexpected changes since I last tested in December 2021)

Jan-04-2022 19-11-27

I'll re-add it.

Would we not end up with both the block gap and the margin being applied?

Thanks for reminding me about the lack of margin-collapsing for flexbox.

In this PR there is overlap of margins between columns. I've had a play around, and to me it seems okay in the editor as I can overcompensate to get the effect I want using a combination of axial margins and gap.

This PR locks the columns layout into flex for now via __experimentalLayout support.

Is there something else we should be testing? I recall you mentioned the possibility of regressions in blocks already out there?

@ramonjd ramonjd requested a review from mkaz as a code owner January 4, 2022 08:38
@aaronrobertshaw
Copy link
Contributor

In this PR there is overlap of margins between columns. I've had a play around, and to me it seems okay in the editor as I can overcompensate to get the effect I want using a combination of axial margins and gap.

The column stacking part of the equation isn't an issue. I confused the column/block.json with the columns/block.json earlier and thought individual columns also had margin block support. They don't so that spacing is solely dependent on the block gap.

Is there something else we should be testing? I recall you mentioned the possibility of regressions in blocks already out there?

From memory, that comment was related to the content inside a column. Column blocks out in the wild potentially have floated contents so forcing them to display as flex containers could break their layout. This PR is only directly related to the parent Columns block so shouldn't be an issue.

Sounds like this is ready to go. 🚢

@youknowriad
Copy link
Contributor

I was thinking about this and 5.9. 5.8 doesn't have gap support at all in columns meaning if we don't land this in 5.9, it won't be considered a regression like in the Gutenberg plugin where the block used to have block gap support.

So given potential impact of this PR, I was thinking that maybe it's fine to just land it in Gutenberg plugin for now? Thoughts?

@ramonjd
Copy link
Member Author

ramonjd commented Jan 4, 2022

I was thinking that maybe it's fine to just land it in Gutenberg plugin for now? Thoughts?

Thanks for your guidance on this one.

Landing in the plugin sounds like a safer bet. I know there's some pressure in relation to 5.9 and it would help to have the breathing space to monitor/debug/garner feedback just in case we're breaking unknowns.

@youknowriad youknowriad removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jan 5, 2022
@ramonjd ramonjd merged commit d9cb56c into trunk Jan 5, 2022
@ramonjd ramonjd deleted the try/no-css-variable-block-gap-columns-block branch January 5, 2022 21:07
@github-actions github-actions bot added this to the Gutenberg 12.4 milestone Jan 5, 2022
@umhan35
Copy link

umhan35 commented Jan 20, 2022

Hi all. My site is ugly now due to this breaking-change PR. There were 2em of gap between columns but now it's 0.5em. 5.8 doesn't have a block gap support yet so can't change in the editor. Is there a workaround for 5.8? I am rolling back to 12.3.2 but it's not a long-term solution. Thanks!

@ramonjd
Copy link
Member Author

ramonjd commented Jan 20, 2022

Hi all. My site is ugly now due to this breaking-change PR. There were 2em of gap between columns but now it's 0.5em. 5.8 doesn't have a block gap support yet so can't change in the editor. Is there a workaround for 5.8? I am rolling back to 12.3.2 but it's not a long-term solution. Thanks!

Hi @umhan35

Sorry to hear that! Thanks for commenting here.

The CSS var was creating a bunch of conflicts, creating more problems than it solved. This PR was a result of limiting it to layout-based blocks.

Are you able to edit your site's theme.json (assuming you have a block-based theme like TT1 Blocks )?

You could try enabling blockGap support for the columns block.

So, settings.spacing.blockGap: true and settings.blocks['core/columns'].spacing.blockGap:true

...
    "settings": {
          ...
                "spacing": {
                      "blockGap":true,
                         ...
                   },
                  ...
		"blocks": {
                        ...
			"core/columns": {
				"spacing": {
					"blockGap": true
				}
			}
		}
   }

and then head to the editor and adjust the block gap setting for that particular block:

Jan-20-2022 17-51-04

If none of these options are available to you then I think you've done the right thing in rolling back for now.

WordPress 5.9 will be released early this year so 🤞 this will fix this particular issue for you.

Hope that helps for now. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Columns Affects the Columns Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants