Problem/Motivation

This problem occurs if content is added to a Layout builder and that content includes an element styled with a fixed width wider than the width of the column.
The column will assume the width of the wider child element, breaking the column layout.

This was discovered (and easy to reproduce) with the comment block, but this issue will happen with any content styled wider than the column width.

How this was discovered:

Steps to reproduce (also see youtube recording )

- Vanilla Drupal 8 (I used simplytest.me to verify)
- Activate Layout Builder module
- Activate Layout Builder on Article
- Modify Layout with two columns with body left and comments to the right
- Enter a artice (the comment form shows underneath instead beside)
- Enter comments
- Save

The comments appear below the body instead of to the right

screenshot

Proposed resolution

Most likely resolution: Add Javascript that detects if a column includes a fixed width element that would cause the column to break to another line. In these cases, the columns should still break to another line, but their width should also be set to 100% (essentially the same behavior as what would take place at narrower screen widths, as the layouts are responsive)

Possible alternative: Add Y-scrolling to columns that would otherwise break to another line. This couuld

Approach that was discussed that will most likely not be used: setting the columns to overflow: hidden would also address the symptoms, but was considered a nonviable solution as it could potentially limit access to important content or inputs.

Remaining tasks

Get feedback on solution, ideally from real-world users.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

CommentFileSizeAuthor
#73 3028979-73.patch28.02 KBgauravvvv
#67 interdiff_54_67.txt597 bytesarshadkhan35
#67 3028979-54_0_reroll_against_8.9.x_branch.patch32 KBarshadkhan35
#65 interdiff_62-65.txt964 bytesvsujeetkumar
#65 3028979_65.patch33.74 KBvsujeetkumar
#62 interdiff_60-62.txt2.02 KBvsujeetkumar
#62 3028979_62.patch34.38 KBvsujeetkumar
#60 interdiff_59-60.txt493 bytesvsujeetkumar
#60 3028979_60.patch32.45 KBvsujeetkumar
#59 3028979-59.patch32.58 KBvsujeetkumar
#54 interdiff_51-54.txt8.12 KBbnjmnm
#54 3028979-54.patch33.52 KBbnjmnm
#51 3028979-51.patch34.76 KBbnjmnm
#51 interdiff_48-51.txt2.1 KBbnjmnm
#51 3028979-51-FAIL.patch34.78 KBbnjmnm
#48 3028979-48.patch32.65 KBbnjmnm
#48 interdiff_41-48.txt35.1 KBbnjmnm
#48 3028979-48-FAIL.patch32.67 KBbnjmnm
#48 scroll-behavior.png136.49 KBbnjmnm
#41 interdiff_37-41.txt2.44 KBbnjmnm
#41 3028979-41.patch16.01 KBbnjmnm
#41 3028979-41-FAIL.patch14.35 KBbnjmnm
#41 interdiff-41-to-41fail.txt6.48 KBbnjmnm
#37 interdiff_35-37.txt421 bytesbnjmnm
#37 3028979-37.patch15.99 KBbnjmnm
#37 3028979-37-FAIL.patch18.29 KBbnjmnm
#35 3028979-35.patch15.99 KBbnjmnm
#35 interdiff_29-35.txt13 KBbnjmnm
#35 3028979-35-FAIL.patch17.31 KBbnjmnm
#29 3028979.29.patch9.92 KBbnjmnm
#29 interdiff_27-29.txt6.73 KBbnjmnm
#27 3028979-27.patch10.52 KBbnjmnm
#25 3028979-25.patch12.58 KBbnjmnm
#25 3028979-25-FAIL.patch11.11 KBbnjmnm
#25 interdiff_22-25.txt4.78 KBbnjmnm
#22 3028979-22.patch10.18 KBbnjmnm
#22 interdiff_16-22.txt4.57 KBbnjmnm
#20 2994909-52-reroll.patch24.09 KBbnjmnm
#16 3028979-16.patch9.97 KBbnjmnm
#16 3028979-16-test-only-FAIL.patch8.5 KBbnjmnm
#16 interdiff_10-16.txt4.37 KBbnjmnm
#10 3028979-10.patch10.08 KBbnjmnm
#10 3028979-10-test-only-FAIL.patch8.61 KBbnjmnm
#5 3028979-4.patch1.47 KBbnjmnm
#5 AfterPatch.png240.85 KBbnjmnm
#5 BeforePatch.png219.37 KBbnjmnm
#2 screencapture-d016p-ply-st-node-1-2019-01-28-16_34_22.png259.3 KBparijke

Comments

parijke created an issue. See original summary.

parijke’s picture

parijke’s picture

Issue summary: View changes
bnjmnm’s picture

Version: 8.6.7 » 8.7.x-dev
bnjmnm’s picture

StatusFileSize
new219.37 KB
new240.85 KB
new1.47 KB

This was due to the comment form having inputs styled wider than the layout builder column it was placed in. This means the layout could potentially break if it contained any element with a fixed width wider than the column.
To fix this, I added overflow: hidden to the layout columns. This was previously not set, so it used the default visible.

bnjmnm’s picture

Status: Active » Needs review
amit.drupal’s picture

Assigned: Unassigned » amit.drupal
amit.drupal’s picture

Assigned: amit.drupal » Unassigned
Status: Needs review » Needs work

@bnjmnm Test Patch #5 on Drupal 8.7.x-dev and Bartik 8.7.0-dev.
- Modify Layout with two columns with the body left and comments to the right
- Enter an article (the comment form shows underneath instead beside)
- Enter comments
- Save

Content display in a single layout. After apply patch content display in the single layout.

Patch is not working properly.

bnjmnm’s picture

@amit.drupal - Since your steps match those I took when creating the patch, I'd like to confirm the CSS in this patch was loaded
Could you check with chrome inspector and confirm the css added in the patch is active while testing?
If using a two column layout, the rule you want to look for is:
.layout--twocol-section > .layout__region { overflow: hidden; }

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new8.61 KB
new10.08 KB

This would be good to get in 8.7, so I've written tests to help reduce review-ambiguity. 3028979-10-test-only-FAIL.patch doubles as an interdiff.

If subsequent manual reviews do not see the issue addressed, please confirm the CSS rules are in place as mentioned in #9

The last submitted patch, 10: 3028979-10-test-only-FAIL.patch, failed testing. View results

xjm’s picture

Title: Layout Builder (Two Columns) does not show correctly with Bartik » The comment form breaks multi-column Layout Builder layouts in Bartik
bnjmnm’s picture

Title: The comment form breaks multi-column Layout Builder layouts in Bartik » Blocks with fixed width elements can break multi-column Layout Builder layouts
Issue summary: View changes
tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Bartik +Blocks-Layouts

That test is *awesome*.
And the fix is clear and correct.
Thanks @bnjmnm!

xjm’s picture

Status: Reviewed & tested by the community » Needs work

It is indeed an awesome test!

I was both impressed by and nervous about that evaluateScript(), so I checked HEAD...

[ibnsina:drupal | Wed 15:03:45] $ grep -rl "evaluateScript" * | grep -v "vendor"core/tests/Drupal/FunctionalJavascriptTests/JavascriptGetDrupalSettingsTest.php
core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php
core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php
core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php
core/modules/ckeditor/tests/src/FunctionalJavascript/AjaxCssTest.php

So there's plenty of precedent in HEAD for using it. One test even has:
$session->evaluateScript('window.jQuery("#data_div").data("testkey")')

...so 👍.

Other than that, just a few test nitpicks:

  1. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,174 @@
    +  const FIELD_UI_PREFIX = 'admin/structure/types/manage/bundle_for_testing_fe';
    ...
    +    $this->createContentType(['type' => 'bundle_for_testing_fe']);
    ...
    +    $this->addDefaultCommentField('node', 'bundle_for_testing_fe');
    

    Bundle for testing iron? I don't know what fe stands for here. We should avoid using abbreviations in Drupal code (including test code).

  2. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,174 @@
    +    // Four column layout does not have additional config, skip this step.
    

    Nit: "Four-column" (with a hyphen) because it's a phrase modifying "layout".

  3. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,174 @@
    +    // The first column gets a Body block, the rest get Comments, which have
    +    // child elements wider than any column widths.
    

    How do we know for sure this is the case? This test could become a false positive if Bartik CSS changes for comments. Generally we want to add assertions for something like this to make sure the test is a true pass, and/or use a dedicated test fixture that forces whatever condition caused the bug before it was fixed.

Overall this is awesome and it's great to see that we have a way to test with. Thanks!

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new4.37 KB
new8.5 KB
new9.97 KB
  1. #15.1: Iron testing has matured to Front End testing
  2. #15.2: nit fixed
  3. #15.3:
    Generally we want to add assertions for something like this to make sure the test is a true pass, and/or use a dedicated test fixture that forces whatever condition caused the bug before it was fixed.

    That is a very good point, especially since it turned out the issue is not specific to the comment form - only discovered while using it. I changed the test to use a body field with an inline style that slightly exceeds the width of the widest possible column in Bartik. Everything related to comments was removed.
    I also wanted to make sure the inline style approach was acceptable and not just leftover habits from working in React. I did a search on other test files and confirmed there were other examples of inline styles being used in tests

The last submitted patch, 16: 3028979-16-test-only-FAIL.patch, failed testing. View results

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

#16 addresses #15 and I have no other concerns. What a cool test!

phenaproxima’s picture

Status: Reviewed & tested by the community » Needs work

Sorry, a few very minor things (the biggest concern is documenting the rationale of the test):

  1. +++ b/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/css/layout_builder_test_css_transitions.test.css
    @@ -0,0 +1,7 @@
    +  /* CSS transitions. */
    +  transition: none !important;
    

    Not sure this comment adds anything. :)

  2. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,170 @@
    +  public static $modules = [
    

    Should be protected.

  3. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,170 @@
    +    $this->assertEquals(1, count(array_unique($block_positions)));
    

    This can be assertCount(), for one less set of parentheses.

I was going to ask how the test can guarantee that the overflowing body field does, in fact, overflow the column, but then I saw what Ben said:

I changed the test to use a body field with an inline style that slightly exceeds the width of the widest possible column in Bartik.

I think I would like this to be explicitly stated in a comment in the test (namely why Bartik was chosen, and that the test relies on details of Bartik), but it makes sense to me otherwise. +1 RTBC once these nits are addressed.

bnjmnm’s picture

StatusFileSize
new24.09 KB

♻️🥖Reroll + addressed all the feedback in #19 (the level of detail is good stuff).

ALSO realized that the test was still loading the comment module & permissions even though it's no longer used in the test, so that's gone.

bnjmnm’s picture

Status: Needs work » Needs review
bnjmnm’s picture

StatusFileSize
new4.57 KB
new10.18 KB

If possible, please act as if #20 never happened.

This patch addresses everything in #19.
In the interdiff, you'll also see changes to the test made due to the reroll and an update to an outdated comment.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Looks great, thanks!

xjm’s picture

Status: Reviewed & tested by the community » Needs review

Thanks @bnjmnm! All good improvements. One thing still stands out though:

+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
@@ -0,0 +1,175 @@
+          'value' => '<div style="width:469px;">I am a fixed width slightly wider than the widest possible column in Bartik.</div>',

Bartik could still change its widest possible column in the future. That's we usually want some kind of an assertion that will fail if Bartik makes a change like that, or to create a different test theme fixture that has the same properties as the one that cause this bug, and test against that instead.

bnjmnm’s picture

StatusFileSize
new4.78 KB
new11.11 KB
new12.58 KB

Good call in #24, removed Bartik from the test and added a module with CSS that replicates the symptoms of the issue.

Also want to mention that I noticed that the layout_builder_test_css_transitions module has a slightly different naming convention than Layout Builder's other the test modules. I considered renaming but decided against as this module is present in several other close-to-completion layout builder issues and will be removed when #2901792: Disable all animations in Javascript testing is completed.

The last submitted patch, 25: 3028979-25-FAIL.patch, failed testing. View results

bnjmnm’s picture

StatusFileSize
new10.52 KB

Reroll - the size difference from #25 is because the layout_builder_test_css_transitions module is now in HEAD.

phenaproxima’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/layout_builder/tests/modules/layout_builder_front_end_test/layout_builder_front_end_test.libraries.yml
    @@ -0,0 +1,4 @@
    +layout_builder.front_end:
    

    Nit: Why isn't this library called layout_builder.front_end_test?

  2. +++ b/core/modules/layout_builder/tests/modules/layout_builder_front_end_test/layout_builder_front_end_test.module
    @@ -0,0 +1,14 @@
    + * Attaches CSS to for testing Layout Builder presentation.
    

    "Attaches CSS to for testing"? :)

  3. +++ b/core/modules/layout_builder/tests/modules/layout_builder_front_end_test/layout_builder_front_end_test.module
    @@ -0,0 +1,14 @@
    +  // Unconditionally attach an asset to the page.
    +  $attachments['#attached']['library'][] = 'layout_builder_front_end_test/layout_builder.front_end';
    

    Nit: I don't think the comment is adding much, so it can probably go away. :)

  4. +++ b/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/css/layout_builder_test_css_transitions.test.css
    @@ -2,6 +2,5 @@
    -  /* CSS transitions. */
       transition: none !important;
    

    Seems out of scope?

  5. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,172 @@
    + * This test exists to surface visual issues that may not be present with the
    + * test theme's default styling.
    

    Nit: There should be a blank line after this paragraph.

  6. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,172 @@
    +  protected static $modules = [
    +    'layout_builder',
    +    'block',
    +    'node',
    +    'layout_builder_test_css_transitions',
    +    'layout_builder_front_end_test',
    +  ];
    

    This needs an @inheritdoc comment.

    Also, I wonder why we don't merge the test_css_transitions module with the front_end_test module, since they seem to have an overlapping scope. However, that's not something we need to do in this issue.

  7. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,172 @@
    +    $this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas input[type="submit"][value="Remove"]'));
    +    $remove_button = $assert_session->waitForElementVisible('css', '#drupal-off-canvas input[type="submit"][value="Remove"]');
    +    $remove_button->click();
    

    This seems a bit strange. It should probably be something like:

    $remove_button = $assert_session->waitForElementVisible(...);
    $this->assertNotEmpty($remove_button);
    $remove_button->press();
    
  8. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,172 @@
    +    $assert_session->linkExists('Add Section');
    

    There's no need for this anymore; $page->clickLink() will automatically do a similar assertion.

  9. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,172 @@
    +    $this->assertNotEmpty($assert_session->waitForElementVisible('css', "#drupal-off-canvas a:contains(\"{$layout_label}\")"));
    +    $page->clickLink($layout_label);
    

    This could be something like:

    $link = $assert_session->waitForElementVisible(...);
    $this->assertNotEmpty($link);
    $link->click();
    
  10. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,172 @@
    +    if ($layout_label !== 'Four column') {
    

    This condition should probably be an additional boolean parameter passed to the test method, not hard-coded for a particular layout.

  11. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,172 @@
    +      $add_block = $assert_session->waitForElementVisible('css', "[data-region=\"{$region}\"] a:contains(\"Add Block\")");
    +      $add_block->click();
    

    To prevent a possible fatal error if the element is not visible, we should add $this->assertNotEmpty($add_block).

  12. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,172 @@
    +      $this->assertNotEmpty($assert_session->waitForElementVisible('css', "#drupal-off-canvas a:contains(\"Body\")"));
    +      $page->clickLink('Body');
    

    This should also probably be refactored to be waitForElementVisible(); assertNotEmpty(); click();

  13. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderFrontEndTest.php
    @@ -0,0 +1,172 @@
    +      $add_block_button = $assert_session->waitForElementVisible('css', '#drupal-off-canvas input[type="submit"][value="Add Block"]');
    +      $add_block_button->click();
    

    Needs $this->assertNotEmpty() to prevent a potential fatal error.

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new6.73 KB
new9.92 KB

Addressed feedback. Removed all changes to layout_builder_test_css_transitions as that module is now in HEAD and the changes are now out of scope (and don't change functionality)

lauriii’s picture

Status: Needs review » Needs work

Using overflow could lead to worse problems than a broken layout. For example, there could be a button or action which would be hidden on certain screen widths, potentially preventing users from using some functionalities on the site. I'm not sure if there's a generic solution that could be applied, other than trying to eliminate all static widths in core, and encourage others to do the same.

phenaproxima’s picture

I'm not sure if there's a generic solution that could be applied, other than trying to eliminate all static widths in core, and encourage others to do the same.

+1, but that seems like quite a heavy undertaking and I ran into this bug today while trying to build a media demo using the layout builder. It is all too easy to encounter this problem in the course of normal page-building tasks, especially once you bring media into the picture. Besides, avoiding static widths is not always possible (embedding a video from a third-party source is a prime example).

One possible approach here, although it sucks, is to not hide horizontal overflow, but to allow it to scroll. I'm well aware that horizontal scrolling is awful (and I don't know if it's kosher from an accessibility standpoint, for that matter), but that might be an acceptable compromise until everything in core can scale correctly.

lauriii’s picture

Static width elements should be avoided at all costs since they cause problems outside of layout builder with responsiveness. We should definitely add support for rendering oembed media entities with a fluid width.

I would support letting layouts break gracefully when they contain static width elements. Layout builder is already responsive, so the positionings shouldn't be taken as absolute. This would in most cases provide better UX compared to letting elements overflow one way or another.

xjm’s picture

Priority: Normal » Major
Issue tags: +Usability

Hmmm, this is a serious UX bug. The layout builder is basically nonfunctional if you have one of these elements contained in it. It's extremely confusing. (I know because I was utterly stumped by it.)

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new17.31 KB
new13 KB
new15.99 KB

This patch uses the approach suggested in #30 (which is also described as the "Most likely resolution" in the issue summary). There is JS that detects if a column has elements with static widths that exceed the column width. If this is the case, then a class is added to the section that results in all columns being 100% width (which they would also be at widths less than 40em).

I have a personal preference for the horizontal scrolling suggestion in #31, even if its kinda odd. Even then I can see why others may not like it. My main interest is getting some kind of solution to users as soon as possible, and as much as I'd like the column count on wider widths to match the section label , it's already understood that the columns will become 100% wide at certain viewport widths. This just triggers the mobile stacking a little earlier if there's an unfortunately wide static width element. The user experience is still improved.

Status: Needs review » Needs work

The last submitted patch, 35: 3028979-35.patch, failed testing. View results

bnjmnm’s picture

StatusFileSize
new18.29 KB
new15.99 KB
new421 bytes

Small goofs in #35 addressed.

bnjmnm’s picture

Status: Needs work » Needs review

The last submitted patch, 37: 3028979-37-FAIL.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 37: 3028979-37.patch, failed testing. View results

bnjmnm’s picture

StatusFileSize
new6.48 KB
new14.35 KB
new16.01 KB
new2.44 KB

This specific patch has minor fixes so tests pass.

This is a copy of the comment from #35 so it's clear what the primary intent of the patch is

This patch uses the approach suggested in #30 (which is also described as the "Most likely resolution" in the issue summary). There is JS that detects if a column has elements with static widths that exceed the column width. If this is the case, then a class is added to the section that results in all columns being 100% width (which they would also be at widths less than 40em).

I have a personal preference for the horizontal scrolling suggestion in #31, even if its kinda odd. Even then I can see why others may not like it. My main interest is getting some kind of solution to users as soon as possible, and as much as I'd like the column count on wider widths to match the section label , it's already understood that the columns will become 100% wide at certain viewport widths. This just triggers the mobile stacking a little earlier if there's an unfortunately wide static width element. The user experience is still improved.

bnjmnm’s picture

Status: Needs work » Needs review
bnjmnm’s picture

Issue summary: View changes
bnjmnm’s picture

Issue summary: View changes
phenaproxima’s picture

Issue tags: +Needs documentation

So the thing that concerns me about this patch is that, when the JavaScript takes effect and forces the columns into a mobile-ish layout, the user will probably be surprised as hell, because that is very unexpected behavior. To someone who doesn't know to expect it, it will flat-out look like a bug. This is going to need to be documented for sure.

At the very least, the JavaScript should call console.log() with an informative developer-facing message. Even better, IMHO, would be to use our new shiny JavaScript messages API to set a user-facing message explaining why the columns have stopped behaving like columns. Ideally, this behavior would be configurable, since I can envision circumstances under which hiding the overflowing content would be the preferred solution.

bkosborne’s picture

Interesting problem. My personal preference is that this is up to the site builder/designer to recognize and fix by applying the 100% width to the fixed width elements. I agree it's may be a DrupalWTF to have the columns of a layout break like this, but I think it's also a DrupalWTF that Drupal would have JS that dynamically changes fixed widths of elements. I think a designer would be more frustrated trying to debug why one of their fixed with blocks is now 100% width (especially since it comes from some unknown JS) than to figure out that the columns broke because a fixed width element was inserted. The solutions presented here are not ideal because there's no obvious way this should be fixed in an automated manner.

bnjmnm’s picture

In Drupal slack, @aaronmchale made the following suggestion

Part of me also thinks just include the three possible resolutions as configuration options, since it's hard to predict which approach people will want

.

While this certainly introduces a bit complexity, the tradeoff seems worthwhile. Here are a few of the reasons that come to mind:

  1. Making this a layout config option would mean not having to introduce new forms
  2. The presence of the option when adding a layout to a section will indirectly let users know this column behavior is something they should be aware of. Even if the option they choose results in confusing behavior, the confusion will potentially be reduced as it relates to a form option they saw earlier
  3. Whatever overflow-behavior option is selected the first time the field is used will become the default value of the field on all subsequent occurrences of the form. The user will likely want the same choice each time, so hopefully this is a setting the user only has to think about one time.
bnjmnm’s picture

StatusFileSize
new136.49 KB
new32.67 KB
new35.1 KB
new32.65 KB

This is an implementation of the suggestion from @aaronmchale -- section configuration now includes an "Column Overflow Behavior" option.

The first time a section is added, the value chosen is stored in State per-user and becomes the default option for all additional sections added.

The fail patch comments the CSS for each option instead of being test-only. Otherwise the tests would fail when no "Column Overflow Behavior" field is found, instead of failing on the behavior that this patch was built to address.

The last submitted patch, 48: 3028979-48-FAIL.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 48: 3028979-48.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new34.78 KB
new2.1 KB
new34.76 KB

Made a few changes to #48 so tests pass.

The last submitted patch, 51: 3028979-51-FAIL.patch, failed testing. View results

tim.plunkett’s picture

Not sold on that amount of text in the UI but it sure seems to work.

  1. +++ b/core/modules/layout_builder/layouts/fourcol_section/layout--fourcol-section.html.twig
    @@ -10,14 +10,8 @@
    -{%
    -  set classes = [
    -    'layout',
    -    'layout--fourcol-section',
    -  ]
    -%}
     {% if content %}
    -  <div{{ attributes.addClass(classes) }}>
    +  <div{{ attributes }}>
    

    While we can change these templates, it won't have an effect on 99% of sites, since these are copied into Stable theme.
    Is there a way to accomplish what is needed without touching the templates?

  2. +++ b/core/modules/layout_builder/src/Plugin/Layout/MultiColumnLayoutBase.php
    @@ -0,0 +1,169 @@
    +      '#title' => $this->t('Column Overflow Behavior'),
    

    Case should be "Column overflow behavior"

  3. +++ b/core/modules/layout_builder/src/Plugin/Layout/MultiColumnLayoutBase.php
    @@ -0,0 +1,169 @@
    +      '#default_value' => \Drupal::state()->get($this->overflowDefaultValueKey, 'js-layout-section--overflow-responsive'),
    

    This is really nice of us. Maybe too much? Not sure. But either way, this is injectable

  4. +++ /dev/null
    @@ -1,79 +0,0 @@
    -abstract class MultiWidthLayoutBase extends LayoutDefault implements PluginFormInterface {
    

    I know it's internal, but I think we should keep this around and deprecate it.

bnjmnm’s picture

StatusFileSize
new33.52 KB
new8.12 KB

#53(intro)

Not sold on that amount of text in the UI

. It's definitely an unweildy chunk of words, but I think it's important for that info to be there. I stuffed most of it in a details element so things are less noisy while still making the information available to users when needed.

#53.1

While we can change these templates, it won't have an effect on 99% of sites, since these are copied into Stable theme.
Is there a way to accomplish what is needed without touching the templates?

The change to the template isn't actually necessary, it was just removing code that is redundant now that the four column template has the classes generated by MultiColumnLayoutBase. Nothing bad happens if the template is unchanged, so I switched it back to its original form.

#53.2 Changed case

#53.3

This is really nice of us. Maybe too much? Not sure. But either way, this is injectable

Injected state. I'm into being nice here, since the option they choose will likely be the same for each section, and the behavior could be really confusing/frustrating if sections are inadvertently set to different overflow behaviors.

#53.4

I know it's internal, but I think we should keep this around and deprecate it.

Did the deprecation. Is a CR not necessary since this is internal, or should that still happen?

diamondsea’s picture

Just to toss some other ideas in the mix at the last minute, the panel contents could also be resized using something like

1) Scale the content

.layout__region--content { transform: scale(.5) }

or more dynamically scale it to the contents using something like CSS Transform Scale element to fit its parent (and possibly add a UI element indicating it has been scaled down).

2) Use ellipses for truncated text

.layout__region--content { text-transform: ellipsis }

3) Fade out cropped content

Use a gradient to fade out the content at the bottom or right edges to indicate it has been cropped.

4) Perhaps make the large block of help text expandable with a help icon or "Show Help" link that expands when clicked.

All the above options could also be added as choices the user could select as the Column Overflow Behavior.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

tim.plunkett’s picture

Status: Needs review » Needs work

I personally think this is too flexible. Layout Builder has achieved success by being customizable from contrib, but opinionated within core.
I'd like to pick a single solution and document how to accomplish other approaches in custom code.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new32.58 KB

Re-roll patch created for 9.1.x, Please review.

vsujeetkumar’s picture

StatusFileSize
new32.45 KB
new493 bytes

Fixed test, Please review.

Status: Needs review » Needs work

The last submitted patch, 60: 3028979_60.patch, failed testing. View results

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new34.38 KB
new2.02 KB

Fixing test.

Status: Needs review » Needs work

The last submitted patch, 62: 3028979_62.patch, failed testing. View results

tim.plunkett’s picture

  1. +++ b/core/modules/layout_builder/layouts/fourcol_section/layout--fourcol-section.html.twig
    @@ -12,9 +12,9 @@
       set classes = [
    -    'layout',
    -    'layout--fourcol-section',
    -  ]
    +  'layout',
    +  'layout--fourcol-section',
    +]
    

    The original indentation seemed fine?

  2. +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderColumnOverflowTest.php
    @@ -0,0 +1,320 @@
    +    'layout_builder_test_css_transitions',
    

    This module was replaced with css_disable_transitions_test which is loaded on all classes extending WebDriverTestBase, so this can be removed.

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new33.74 KB
new964 bytes

@tim.plunkett Done with the changes mentioned in #64, Please review.

Status: Needs review » Needs work

The last submitted patch, 65: 3028979_65.patch, failed testing. View results

arshadkhan35’s picture

Version: 9.1.x-dev » 8.9.x-dev
Status: Needs work » Needs review
StatusFileSize
new32 KB
new597 bytes

Re-rolling #54 patch against 8.9.x branch.

Status: Needs review » Needs work

The last submitted patch, 67: 3028979-54_0_reroll_against_8.9.x_branch.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gauravvvv’s picture

Status: Needs work » Needs review
StatusFileSize
new28.02 KB

I have attached patch for 11.x. I have fixed the test failures. Not adding the interdiff as patch #67 doesn't apply anymore.

smustgrave’s picture

Version: 9.5.x-dev » 11.x-dev
Status: Needs review » Needs work

Can we confirm this is still an issue on D10?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.