Problem/Motivation
Layout discovery provides a handful of layout plugins that do not work with Layout builder's concept of section based layouts. Virtually all of layout discovery's layout plugins are stacked, and Layout builder operates on the idea that end users would choose to make a layout stacked with the provided user interface if they wanted that feature.
Proposed resolution
Provide a set of layout plugins specific to layout_builder.
For the 2 and 3 column layouts allow columns widths by configuration instead of multiple layouts for every width combination. This will make the list of layouts to be shorter and existing layouts to update the widths.
- 2 column layout with column width configuration options 50%/50%, 33%/67%, 67%/33%, 25%/75%, 75%/25%
- 3 column layout with column width configuration options 25%/50%/25%, 33%/34%/33%, 25%/25%/50%, 50%/25%/25%
- 4 column
Hide the existing layout_discovery provided plugins except the 1 column layout in Layout Builder's UI.
Remaining tasks
Review
User interface changes
New layouts to choose from when using Layout Builder UI. Existing stacked layouts could not be added.
"Choose a layout" before

"Choose a layout" updated

Layouts used and configure form

API changes
none
Data model changes
none
| Comment | File | Size | Author |
|---|---|---|---|
| #49 | 2938132-layouts-49.patch | 791 bytes | tim.plunkett |
| #45 | 2938132-layouts-45-interdiff-full.txt | 5.43 KB | tim.plunkett |
| #45 | 2938132-layouts-45-interdiff.txt | 2.34 KB | tim.plunkett |
| #45 | 2938132-layouts-45.patch | 24.9 KB | tim.plunkett |
| #38 | 2938132-38-layouts.patch | 22.79 KB | tedbow |
Comments
Comment #2
xjmThese sound reasonable to me.
How should we hide the old ones from LB?
Comment #3
eclipsegc commentedThat's an open question, and Tim and I have been discussing it. I think we have a couple ideas that could work. We'll formalize a suggestion in the next day or so and see where it goes from there.
Eclipse
Comment #4
xjmMeanwhile, patch for the new ones.
I think the fourcol one is still broken but my laptop just went through an adventure that is scarily like a logic board and/or encrypted HD partition corruption, so trying to upload this before the work is lost..
Comment #5
xjmIn the process of copying the layouts I noticed there are some old
@todore: flex layouts not being able to be stabilized until IE9 and 10 support is dropped. But no explicit followup issue seems to have been listed, so I'm not sure they ever got copied over.Comment #7
eclipsegc commentedFor the time being, Tim and I had discussed keeping these layouts in layout_builder. You disagree?
Eclipse
Comment #8
xjmSure, that makes sense. I'll move them (and remove the Stable addition).
Comment #9
tim.plunkettComment #11
tedbowMoving into layout builder and using
hook_plugin_filter_TYPE__CONSUMER_alterto remove the unneeded layout_discovery layouts for the "choose layout section". Not sure if we should remove them from all consumers.Comment #13
aaronmchaleThis might be outside the scope of this issue a little bit, but I wonder if instead of hardcoding the Layouts to be filtered out we should instead provide some kind of configuration for hiding Layouts?
For example perhaps a site has other modules which provide other layouts but are not needed and so are cluttering up the "Choose a layout" list.
Comment #14
tim.plunkettThat functionality is provided by http://www.drupal.org/project/layout_builder_restrictions
Comment #15
tedbowUnrelated change. Not sure it got in. Reversed.
Should we actually remove these layouts for all consumers?
You effectively these older layouts by combining the layouts provided by layout_builder. If you are using layout_builder along with other modules that use layout plugins it will be weird that you see different layouts in different places when the person using the layouts might not be the site builder so doesn't know anything about the different modules.
On the other hand layout_discovery is stable so sites might have workflows around these layouts.
I think there are couple options.
1. Add a BC_ flag that will hide the old these layouts for all consumers for sites that turn on layout_builder after this issue is committed. Similar to what we have done for normalizers in the serialization module.
2. Encourage contrib modules to also hide these layouts in the same way. There are not too many modules right now that use layout plugins I would think.
Need an empty line here.
Comment #16
tim.plunkettI'm not sure that we want to commit to shipping all of these exact layouts, especially the different widths of the 3 column.
We talked a while ago about a 3 column layout with a configuration option to pick between different widths, and varying the CSS classes by that option. I think we should revisit that here, and make sure we really like the layout options we're providing.
Comment #17
tedbowOk like the idea of #16. Then could switch width of a two column layout after it is placed.
Comment #18
tedbowforgot the patch
Comment #19
tedbowInstead of using the annotation in the plugin class I used the 'class' property in the yml file.
I think it is better because you are able to quickly all the layouts the module provides in 1 yml file.
I added all this different options for the 2 column layout. Because since we already the ability to have as narrow columns of 25% in the for column you might as well have it here in the 2 column to line up.
34%/66% to 33%/67% so that first column would line up if it was below a 3 column 33%/34%/33%.
Same for 66%/33%.
Comment #20
tedbowfixed #19.3
Comment #23
tedbowFix test failure because we now need save layout configuration form when adding a section.
Comment #24
tedbowDon't need this anymore since they are added in the class.
Adding 25%/25%/50% and %50/25%/25%
I think that covers all the 1/3, 1/4 splits across 2 and 3 columns
Comment #25
tedbowanother self review. ⚡️Test passing!
We don't need the second selector line. Maybe copy/paste error?
All of these selectors can be replaced by
.layout--fourcol-section > .layout__regionDon't need second selector
Need to add
@interalWill this always be internal or only until module stable. Seems like it would handy for other modules to extend.
Need blank line
Comment #26
tedbowComment #27
tedbowsmaller images for summary
And fixed one of the labels for the width options missing a "%"
Comment #28
tedbowAdded testing for correct layouts available.
Comment #29
aaronmchaleJust adding my support here for #16, we can provide configuration for Layouts, so may as well make full use of them and provide as much customisation as possible, Bootstrap Layouts is a good example of making full use of configuration to style the Layout.
Comment #30
tim.plunkettSigning off on this, but want @DyanneNova's signoff as well.
Comment #31
tedbowReroll
Comment #32
dyannenovaThis looks good to me!
Comment #33
xjmhook_plugin_filter_TYPE__CONSUMER_alter()approach. I think that's a good way to address this issue without a BC break, and glad to see it being included in the same patch.Actually, it's a four-column layout. This typo may or may not ahem, cough, ahem date back to my initial patch.
Comment #34
xjmThis is a sweet feature.
I think it needs test coverage though; NW for that.
Glad to see this tested!
Comment #35
xjmComment #36
tim.plunkettI can answer #34.4:
The nice thing about
hook_plugin_filter_TYPE__CONSUMER_alter()is that it's runtime only, and also only for the places that call\Drupal\Core\Plugin\FilteredPluginManagerInterface::getFilteredDefinitions(). And only UIs should use that.So yes, those old layouts won't be "visible" in the sidebar anymore when selecting new ones. But they will still function 100%.
Additionally, this hook only removes them when the provider is
layout_discovery, so any custom code could permanently restore them by altering the plugin definitions to switch the provider to their own custom module.Comment #37
xjmYep, so just manual testing of the UX with a layout that has the old section templates?
Comment #38
tedbow@xjm thanks for the review!
Re #34.2
Here is a test. Adds the 2 & 3 column sections and cycles through all the width options making sure that correct class is applied for each section.
Comment #39
tedbowAdded change record: https://www.drupal.org/node/3020140
Comment #40
tim.plunkettThanks!
Comment #41
aaronmchaleIs the title of the change record the most accurate description of the change? "Layout Builder now ships with single column sections instead of stacked sections", should that say "single row sections" instead of "single column sections"?
Comment #42
tedbow@AaronMcHale thanks good catch. Fixed it.
Comment #43
aaronmchaleGreat, thanks tedbow, looks good now :)
Comment #44
alexpottthree = four :) ah... there is more see comment below.
I think we need to apply the changes above to make the patch comments in css and templates consistent. Plus the
@todois not the necessary as that patch has landed - #2842298: [policy, no patch] Drop IE9 and IE10 support from Drupal 8.4.xNice that this is here - shame we've not landed that yet.
Comment #45
tim.plunkettAgreed with the diff in #44.3, applied that verbatim and then removed all of the links pointing to #2842298: [policy, no patch] Drop IE9 and IE10 support from Drupal 8.4.x
Leaving RTBC.
(interdiff.txt is my changes, interdiff-full.txt includes #44.3)
Comment #46
alexpottCrediting @EclipseGc for creating the issue and offline discussions.
Crediting @AaronMcHale, and myself for issue review and comments.
Crediting @DyanneNova for issue sign off as layout initiative coordinator.
Committed 6cb2397 and pushed to 8.7.x. Thanks!
Comment #48
tacituseu commentedThis introduced test failures on PHP5:
https://www.drupal.org/pift-ci-job/1166382
https://www.drupal.org/pift-ci-job/1165837
Comment #49
tim.plunkettGood catch, this one is thankfully a REALLY easy fix!
Comment #50
effulgentsia commentedCrediting @tacituseu for discovering and reporting #48.
Comment #52
effulgentsia commentedPushed to 8.7.x.