"Issue summary updated as of comment #34

Problem/Motivation

When you add the "Messages" system block to layout builder, it creates hidden block. It isn't able to be modified or deleted.

The source of the issue is that the block--system-messages-block template (in system and all core themes) only renders {{ content }}. Since {{ title_prefix }} is not rendered, there are no contextual links. Since {{ attributes }} are not rendered, there is no ability to drag and drop.

Steps to reproduce

Steps to test -
1. Go to admin site.
2. Go to admin/modules.
3. Enable layout builder
4. Go to admin/structure/block.
5. Place the status messages block to content type.
6. Go to admin/structure/types/manage/article/display/default/layout.
7. Add the messages block.
8. Verify

Before: Demonstrates that there is a hidden block that cannot be modified or deleted

Proposed resolution

Update the core message block templates to leverage the in_preview flag added in #3273317: Add 'in_preview' variable to block and layout templates to render the {{ title_prefix }} so there are contextual links. and {{ attributes }} so we can drag and drop.

Remaining tasks

- Add before screenshot and link to video to proposed resolution
- Write what the proposed resolution and patch does.

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

CommentFileSizeAuthor
#94 B-checked-no-messages.png3.7 KBdanflanagan8
#94 B-checked-w-message.png7.63 KBdanflanagan8
#94 B-unchecked.png7.95 KBdanflanagan8
#94 A-unchecked.png13.76 KBdanflanagan8
#94 A-checked.png7.46 KBdanflanagan8
#93 interdiff_83-93.txt985 bytesjnlar
#93 3137995-93.patch8.04 KBjnlar
#92 message-block-preview-83.png19.52 KBjnlar
#89 after-changes.png13.26 KBjnlar
#89 before-changes.png12.78 KBjnlar
#85 interdiff_27-83.txt6.16 KBjnlar
#83 interdiff_71-83.patch7.08 KBjnlar
#83 3137995-83.patch7.99 KBjnlar
#76 body-yes-links.png11.54 KBdanflanagan8
#76 messages-no-links.png13.27 KBdanflanagan8
#72 3137995-71.patch1.88 KBclayfreeman
#67 interdiff_46-67.txt904 bytesvsujeetkumar
#67 3137995-67.patch11.03 KBvsujeetkumar
#53 Edit layout for Article content items _ Demo.mp42.72 MBPoojita0802
#53 Before Patch_3137995.png202.76 KBPoojita0802
#52 Before-patch-layoutbuilder..png239.68 KBMadhu kumar
#52 After-patch-layoutbuilder.png202.82 KBMadhu kumar
#48 3137995-46-status-message-invisible-in-layout-builder.patch11.01 KBrhovland
#46 3137995-44.patch10.78 KBk_a_l
#42 Screen Shot 2021-04-14 at 4.40.08 PM.png202.76 KBsmithmeagdrupal
#30 interdiff_27-30.txt1.17 KBdeepak goyal
#30 3137995-30.patch12.18 KBdeepak goyal
#27 interdiff_21-26.txt1.04 KBdanflanagan8
#27 3137995--26.patch12.18 KBdanflanagan8
#27 3137995--26--FAIL.patch2.77 KBdanflanagan8
#23 Patch #21.png486.67 KBpriyanka.sahni
#23 After_Local.png138.83 KBpriyanka.sahni
#23 After_Local.gif15.2 MBpriyanka.sahni
#23 After_Sandbox.png160.47 KBpriyanka.sahni
#21 interdiff_12-21.txt2.81 KBdeepak goyal
#21 3137995-21.patch8.37 KBdeepak goyal
#13 interdiff-8-12.txt4.42 KBshaktik
#7 3137995--7.patch1.03 KBdanflanagan8
#8 3137995--8.patch3.41 KBdanflanagan8
#13 fixed-test-case-3137995-12.patch7.84 KBshaktik

Comments

kruser created an issue. See original summary.

kruser’s picture

I kept adding Message blocks, thinking something was broken. Now when I save a Node I get a dozen Message areas displayed. When I go back into layout builder, it won't let me delete them, or even show they exist as blocks on the page.

foreveryo’s picture

I had exactly the same issue.

The problem resides on the block--system-messages-block.html.twig template that does not output the contextual links in purpouse to not render the block if there are no messages.

So, the workaround I used to remove the "Message blocks" is to create a file called "block--system-messages-block.html.twig" under your theme "templates" folder and use the default "block.html.twig" as content of the file. Once you have removed the "Message blocks" you should remove the file "block--system-messages-block.html.twig" to have it styled correctly.

Hope it helps ;-)

nikunj.shah’s picture

Assigned: Unassigned » nikunj.shah
kruser’s picture

@foreveryo nice tip, thanks. I ended up exporting and manually editing the config file, and then re-importing it to get rid of them.

nikunj.shah’s picture

Assigned: nikunj.shah » Unassigned
danflanagan8’s picture

StatusFileSize
new1.03 KB

Here's a patch that might help people with this bug. It updates the block--system-block-messages in Stable template to show contextual links if the messages block is placed using Layout Builder.

There also may be an ugly way to handle moving the Messages block until this issue is fixed if you don't want to apply a patch. You can click the "move" contextual link on a different block in the section. A sidebar will pop up in which you should be able to see the Message block.

UPDATE: The failure is because the patch modifies Stable, which of course is not stable.

danflanagan8’s picture

StatusFileSize
new3.41 KB

I'm also attaching a more ambitious patch that is a much more general and might promote discussion on this bug.

It seems to me that it is useful to know if a block is being rendered in the Layout Builder UI. This bug with the Messages block is one example; there are likely other blocks with this problem either core or contributed. This patch adds a new boolean to the block render array called layout_builder_preview. It can be used in templates directly or it could potentially be used for creating new theme suggestions.

danflanagan8’s picture

Status: Active » Needs review

The last submitted patch, 7: 3137995--7.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 8: 3137995--8.patch, failed testing. View results

shaktik’s picture

Assigned: Unassigned » shaktik

I am working on it.

shaktik’s picture

Status: Needs work » Needs review
StatusFileSize
new7.84 KB
new4.42 KB

Solved test case issue, kindly check

shaktik’s picture

Assigned: shaktik » Unassigned

Status: Needs review » Needs work

The last submitted patch, 13: fixed-test-case-3137995-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

danflanagan8’s picture

Thanks for jumping in @shaktik!

That failed quickedit test seems weird and unrelated to this. Do you think that is related to #3037436: [random test failure] Make QuickEditIntegrationTest more robust and fail proof?

It would be nice to get some conversation going around whether people think the #layout_builder_preview variable would be generally useful for blocks.

shaktik’s picture

Status: Needs work » Needs review

I have tested the failer test case on my local after applying the patch and its working fine.

bash-3.2# ./vendor/bin/phpunit -c core/ --filter testArticleNode core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php
PHPUnit 8.5.5 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest
.                                                                   1 / 1 (100%)

Time: 1.12 minutes, Memory: 8.00 MB

OK (1 test, 103 assertions)

but I am not able to understand why is failing on drupal ci. can anyone suggest me.

jungle’s picture

#15 is a random failure, re-queued.

jungle’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php
    @@ -120,6 +120,7 @@ public function testOnBuildRender($refinable_dependent_access) {
    +      '#layout_builder_preview' => false
    
    @@ -195,6 +196,7 @@ public function testOnBuildRenderWithoutPreviewFallbackString($refinable_depende
    +      '#layout_builder_preview' => false
    
    @@ -324,6 +326,7 @@ public function testOnBuildRenderInPreview($refinable_dependent_access) {
    +      '#layout_builder_preview' => true
    
    @@ -332,6 +335,7 @@ public function testOnBuildRenderInPreview($refinable_dependent_access) {
    +      '#layout_builder_preview' => true
    
    @@ -383,6 +387,7 @@ public function testOnBuildRenderInPreviewEmptyBuild() {
    +      '#layout_builder_preview' => true
    
    +++ b/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php
    @@ -115,6 +115,7 @@ public function testToRenderArray() {
    +      '#layout_builder_preview' => false
    
    @@ -198,6 +199,7 @@ public function testToRenderArrayPreview() {
    +      '#layout_builder_preview' => true
    
    • true -> TRUE, false -> FALSE
    • missing , as the last item in an array.
  2. +++ b/core/themes/stable/templates/block/block--system-messages-block.html.twig
    @@ -4,10 +4,24 @@
    + * there are no messages. Add contextual links only if in the Layout Builder
    + * UI.
    

    Wrapped too early. It should be one line "there are no messages. Add contextual links only if in the Layout Builder UI."

deepak goyal’s picture

Assigned: Unassigned » deepak goyal
deepak goyal’s picture

Assigned: deepak goyal » Unassigned
Status: Needs work » Needs review
StatusFileSize
new8.37 KB
new2.81 KB

hi @jungle
made changes please review.

priyanka.sahni’s picture

Assigned: Unassigned » priyanka.sahni
priyanka.sahni’s picture

StatusFileSize
new160.47 KB
new15.2 MB
new138.83 KB
new486.67 KB

Verified and tested by applying the patch #21.Patch was applied successfully but the issues wasn't fixed yet.Verified and tested on Drupal 9.0.0 and sandbox.

Steps to test -
1. Go to admin site.
2. Go to admin/modules.
3. Enable layout builder
4. Go to admin/structure/block.
5. Place the status messages block to content type.
6. Go to admin/structure/types/manage/article/display/default/layout.
7. Add the messages block.
8. Verify

Patch Applied -
Patch#21

After_Sandbox -
After Patch

After_Local -
After Patch

After_Local -
After Patch

priyanka.sahni’s picture

Assigned: priyanka.sahni » Unassigned
priyanka.sahni’s picture

Status: Needs review » Needs work
danflanagan8’s picture

@priyanka.sahni, that video is awesome!

The messages block is showing up, which I think is an improvement. Can it be dragged around?

The placeholder text misbehaves a little bit because the messages block isn't empty. It has content even when it's in the Layout Builder UI. That's different from other blocks. At least I think that's what's going on.

Ugh, this is my fault. I tested my change to the Stable template on a D8 site. In D9 it looks like the Messages block renders using a template in the system module, which the patch does not alter.

Seeing that there's some real interest in this issue now, I think I'm going to write a test for this. That way we'll be defining exactly what the expected behavior is after the patch. Just thinking now, the test should probably check:

1. the ability to drag the Messages block
2. the presence of contextual links for the Messages block
3. the placeholder text for the Messages block

I'll post a couple patches in the next couple days hopefully.

danflanagan8’s picture

StatusFileSize
new2.77 KB
new12.18 KB
new1.04 KB

The FAIL patch adds a test to LayoutBuilderTest, a FunctionalJavascript test in layout_builder. The new test tests that a Messages block added to the Layout Builder UI has

1. The correct placeholder text
2. Can be dragged to a different section
3. Can be removed

The other patch includes this new test plus it updates the messages block template in the system module. The interdiff just shows this change.

danflanagan8’s picture

Status: Needs work » Needs review
jungle’s picture

+++ b/core/modules/layout_builder/tests/src/Unit/SectionRenderTest.php
@@ -115,6 +115,7 @@ public function testToRenderArray() {
+      '#layout_builder_preview' => false

@@ -198,6 +199,7 @@ public function testToRenderArrayPreview() {
+      '#layout_builder_preview' => true

@@ -254,6 +256,7 @@ public function testContextAwareBlock() {
+      '#layout_builder_preview' => false

false -> FALSE, true -> TRUE.

deepak goyal’s picture

StatusFileSize
new12.18 KB
new1.17 KB

Hi @jungle
Uodated patch please review.

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

Drupal 9.0.10 was released on December 3, 2020 and is the final full bugfix release for the Drupal 9.0.x series. Drupal 9.0.x will not receive any further development aside from security fixes. Sites should update to Drupal 9.1.0 to continue receiving regular bugfixes.

Drupal-9-only bug reports should be targeted for the 9.1.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.2.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

danflanagan8’s picture

I stumbled upon and issue that might be useful here once it is resolved: https://www.drupal.org/node/3027653

mradcliffe’s picture

Version: 9.1.x-dev » 9.2.x-dev
Status: Needs review » Needs work
Issue tags: +NorthAmerica2021, +Easy Out of the Box, +Novice, +Needs reroll, +Needs issue summary update, +Needs manual testing

I performed Novice Issue triage on this issue. There are some clear steps to move this step forward.

The latest patch needs to be re-rolled for Drupal 9.2.x.
Additionally we should update the issue summary with the issue summary update. This could also include providing screenshots in the steps to reproduce section of the issue summary. Adding an After screenshot after we get a working patch for 9.2.x would also be needed.

ijf8090’s picture

I am testing as a Novice at DrupalCon 2021

ijf8090’s picture

Issue summary: View changes
smithmeagdrupal’s picture

I am testing and will edit the issue.

smithmeagdrupal’s picture

Issue summary: View changes
smithmeagdrupal’s picture

Issue summary: View changes
smithmeagdrupal’s picture

Next, I'll post screenshots of the issue

mradcliffe’s picture

I removed Needs issue summary update tag for now.

mradcliffe’s picture

@rhovland is having trouble getting things posted, but wanted to link https://www.drupal.org/project/facets/issues/3027593 as a related issue.

smithmeagdrupal’s picture

StatusFileSize
new202.76 KB

To reproduce the issue, I did the following:
1. Go to admin site
2. Extend> Enable the layout builder module
3. Structure> Block Layout, place Messages (Category: systems) block to content type
4. Go to structure> Content Types> Article> Manage Display> Manage layout
5. Add message block
Screenshot of manage layout issue

smithmeagdrupal’s picture

Just updating that I am stopping my work on this issue today.

k_a_l’s picture

Re-rolling the patch

rhovland’s picture

I'm currently attempting to reroll this patch.

k_a_l’s picture

StatusFileSize
new10.78 KB

Removed part of the patch that references `core/tests/Drupal/KernelTests/Core/Theme/StableDecoupledTest.php`.

k_a_l’s picture

Status: Needs work » Needs review
rhovland’s picture

Double checked @k_a_l s patch

The test StableDecoupledTest was removed in 9.1.x
https://git.drupalcode.org/project/drupal/-/commit/c509626db3fa0927b2bb3...

It was no longer needed in core so the modifications in the patch have been removed.

mradcliffe’s picture

Issue summary: View changes
Status: Needs review » Needs work
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index ec7e0ed7d8..53f912b87c 100644

@K_a_l removed the chunk in the diff that didn't apply and re-uploaded the patch in #30.

@rhovland applied the patch in #44 based on 9.2.x and re-rolled the patch based on the latest HEAD.

So the patch in #44 is correct to review / test.

mradcliffe’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll

Didn't need to move back to Needs work. Also need to remove Needs reroll

Poojita0802’s picture

Assigned: Unassigned » Poojita0802
Madhu kumar’s picture

StatusFileSize
new202.82 KB
new239.68 KB

Patch #48 Applied cleanly and working as expected , block is visible and able to modified the block . Sharing screenshot for reference.

Poojita0802’s picture

Verified and tested patch#44. Patch applied successfully and looks good to me

Testing Steps:
1. Go to admin site.
2. Go to admin/modules.
3. Enable layout builder
4. Go to admin/structure/block.
5. Place the 'messages' block to content type.
6. Go to admin/structure/types/manage/article/display/default/layout.
7. Add the messages block.and verify

Testing Results:
When you add the "Messages" system block to layout builder, it creates hidden block. It isn't able to be modified or deleted.: Fixed

mradcliffe’s picture

Assigned: Poojita0802 » Unassigned
Issue summary: View changes
Issue tags: -Needs manual testing +Needs issue summary update

Thank you for the additional testing and screenshots, @MeaghanSmith and @Poojita0802 and @Madhu kumar.

After we add screenshots we also want to embed or add them in the issue summary so it is easy for someone triaging and reviewing the issue to see the before and after. The video is especially helpful, and I think that a link to the video should be in the issue summary too. (edit) I would keep Meaghan's before screenshot, add Poojita's video as a link, and add Madhu's after screenshot.

Also after we do that we usually remove the "Needs manual testing" tag. I removed it, but I also added "Needs issue summary update". If someone could come in today and format the issue summary with the After screenshot as well as detailing what the Proposed resolution is that would be great!

When updating the issue summary, also try to answer the other sections. If you're unsure, you can mention in a comment that you weren't sure, but you can also ask in Drupal Slack #contribute or #easy-out-of-the-box and ping the Drupal user who wrote or uploaded the patch.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ojchris’s picture

Today I want to work on the issue summary.

ojchris’s picture

Issue summary: View changes
ojchris’s picture

I've updated the proposed solution.

ojchris’s picture

Issue summary: View changes
ojchris’s picture

Issue summary: View changes
ojchris’s picture

Issue summary: View changes
ojchris’s picture

Issue summary: View changes
ojchris’s picture

Issue summary: View changes
ojchris’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

I have made changes to the issue summary.

rachel_norfolk’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for updating the Issue Summary, ojchris37

This looks a lot better now and I think we have enough explanation for the maintainers to commit this.

Thank you all for working on this!

Status: Reviewed & tested by the community » Needs work
vsujeetkumar’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new11.03 KB
new904 bytes

Fixed the fail test, It is related to the "deprecation notices" and move to RTBC as suggested in #65.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 67: 3137995-67.patch, failed testing. View results

danflanagan8’s picture

Hi All! Great work on this.

I was the one way back when who started the approach where we add the layout_builder_preview variable to Block render arrays. I am convinced this is the wrong approach. It's heavy-handed and seems likely to break tests in the contrib space, the same way it required a lot of tests to be updated in core.

I think a better approach will be to piggy-back off of whatever comes out of #3027653: Allow block and layout plugins to determine if they are being previewed. The current approach there looks really good and seems much less likely to break tests in the contrib space. Assuming patch doesn't change too much, the approach here would be to update the Annotation for the Messages block to include the context_definitions and then update the build function of the Messages block to return different values depending on context. In this approach I think we'd only have to make changes to the Message block plugin and the Message template. That seems like a smoother approach.

Regardless of the approach, the tests we have should be great. We're solving the same problem, after all, regardless of how we solve it.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

danflanagan8’s picture

Here's an issue that just landed that I've been keeping an eye on, anticipating that it would make our issue with the Status Message block easy to solve: #3027653: Allow block and layout plugins to determine if they are being previewed

I mentioned this first in #32

Change record is here: Block and layout plugins can now determine if they are being rendered in preview mode

I think it would be great to see if there's a good way to leverage that new feature to create an elegant fix here.

clayfreeman’s picture

Status: Needs work » Needs review
StatusFileSize
new1.88 KB

Trying this with a much smaller patch, thanks to #3027653: Allow block and layout plugins to determine if they are being previewed. Not sure if the test is redundant since this is basically just asserting that a preview fallback string is being used for the messages block; will need a maintainer to render an opinion on this.

danflanagan8’s picture

@clayfreeman, I think you should be able to repurpose the fail test in #27 (which is named as if it's in the 26th comment. Oops!). That test makes sure you can move the block around, which is really what this issue is about.

Not sure what that failed build is about though.

clayfreeman’s picture

@danflanagan8 I believe the test failure was a fluke. I did repurpose a portion of that test, but I think it's sufficient to just check that the preview fallback string appears (since the root cause of not being able to manipulate the block is that it has no content).

danflanagan8’s picture

he root cause of not being able to manipulate the block is that it has no content

I believe the root cause is that the status message block does not render {{ title_prefix }} which means that contextual links don't render as pointed out in #3

danflanagan8’s picture

Status: Needs review » Needs work
StatusFileSize
new13.27 KB
new11.54 KB

Here's what I see after applying the patch in #72. Status message have placeholder text, but no contextual links.

When I hover over the Body block I do get contextual links.

But I guess it's more than just {{ title_prefix }} that we need, because the drag-and-drop functionality relies on the attributes being rendered in the block template, another thing that the status-messages template is missing.

clayfreeman’s picture

Status: Needs work » Postponed

Ah, I see what you mean now. The issue description was deceptively simplistic; it could probably use an update.

I think we should postpone this on #3273317: Add 'in_preview' variable to block and layout templates, which will add the in_preview variable to the block template. I think this issue has a good chance of being committed quickly, then the work here can continue without any scope creep.

danflanagan8’s picture

Issue summary: View changes

@clayfreeman, 100% agree with your idea to postpone. That issue will make this one super easy!

I added a bit to the IS to explain the issue a little more thoroughly.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.

danflanagan8’s picture

Issue summary: View changes
Status: Postponed » Active

Blocking issue just got fixed! No longer postponed.

There's a good fail test in #27 that we can test against. I'm not 100% convinced this is really a novice issue, but I'll leave that tag on and hopefully a novice contributor will take on the challenge!

I'm updating the IS with the latest proposed solution.

danflanagan8’s picture

Status: Active » Needs work

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

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now 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.

jnlar’s picture

Status: Needs work » Needs review
StatusFileSize
new7.99 KB
new7.08 KB

Included a patch trying to follow the IS, uses the test from #27. Please review!

I'm not sure if it's in scope of this issue or not but when using the olivero theme with the updated template, placeholder content is still displayed when 'Show content preview' is unchecked. This is because the olivero theme uses cores block--system-messages-block.html.twig template. I yanked this from oliveros block.html.twig template and it seemed to sort the issue:

    <div{{ content_attributes.addClass('block__content') }}>
      {{ content }}
    </div>

At some point the olivero theme will need to include an override template so the messages block matches the styling of the other blocks when in preview mode.

danflanagan8’s picture

Status: Needs review » Needs work
Issue tags: -Novice

Thanks, @jnlar!

This should be a completely new approach compared to patch 71 (on comment #72), so the interdiff is not especially helpful. I think a more helpful interdiff would be relative to the fail test that you are starting with, which is from comment #27. That way the interdiff will show what the fix is. Also it looks like 71 (aka 72) has different test coverage, which makes the interdiff noisy.

I'm removing the Novice tag now.

jnlar’s picture

StatusFileSize
new6.16 KB

Cheers for pointing that out @danflanagan8, my bad there. I've attached an interdiff against your failed test patch in comment #27

jnlar’s picture

Status: Needs work » Needs review
Bushra Shaikh’s picture

I have applied patch #85. Patch failed .
Got below errors after applying patch.

Checking patch core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php...
error: while searching for:
  }

  /**
   * Tests the Messages block in the Layout Builder UI.
   */
  public function testMessagesBlock() {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();

    $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
    $this->submitForm(['layout[enabled]' => TRUE], 'Save');

    $this->drupalGet("admin/structure/types/manage/bundle_with_section_field/display/default/layout");
    $this->openAddBlockForm('Messages');
    $page->pressButton('Add block');

    $assert_session->assertWaitOnAjaxRequest();
    $assert_session->elementTextContains('css', '.layout__region--content', '"Messages" block');
  }

  /**
   * {@inheritdoc}
   *
    $assert_session->linkNotExists('Add block');
  }

  /**

error: patch failed: core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php:396
error: core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php: patch does not apply
Checking patch core/modules/system/templates/block--system-messages-block.html.twig...
Checking patch core/themes/stable9/templates/block/block--system-messages-block.html.twig...

can be moved to " Needs Work"

danflanagan8’s picture

Status: Needs review » Needs work

@Bushra Shaikh, the file attached with #85 is not a patch, it's an interdiff. That's why it won't apply.

@jnlar, thank you for the updated interdiff! I have a few comments.

1. I think the following code change can be removed. We should be able to rely on the in_preview variable without having to update the block's build method.

+++ b/core/modules/system/src/Plugin/Block/SystemMessagesBlock.php
@@ -31,7 +31,9 @@ public function defaultConfiguration() {
- return [
+ // Use preview fallback by returning an empty render array in preview mode.
+ // The block cannot be manipulated otherwise.
+ return $this->inPreview ? [] : [

2. I'm the one who posted the fail test in #27 (three years ago!), so this one is my fault. Can you remove this line from the docbloc comment of the new test method?

+   * See https://www.drupal.org/project/drupal/issues/3137995.

Other than that I think it looks great! Unfortunately I won't be able to RTBC because I added the fail test. Once it looks good to me, though, I'll try to find someone to RTBC it. Thanks!

jnlar’s picture

Status: Needs work » Needs review
StatusFileSize
new12.78 KB
new13.26 KB

Thanks for the review @danflanagan8,

Regarding 1, I noticed that leaving the blocks build() method as is without $this->inPreview ? [] : [... results in the placeholder content being the message block itself (if it isn't hidden).

If 'Display title' for the messages block is unchecked and 'Show content preview' is checked, and you haven't made changes yet, you won't see anything except for the contextual link icon when you hover over the block in layout builder:

before changes - messages block

After making any change:

after changes - messages block

From what I understand returning an empty render array means we'll use the preview fallback opposed to ::generatePlaceholder in StatusMessages which seems to be the cause.

jnlar’s picture

Status: Needs review » Needs work
danflanagan8’s picture

@jnlar, I see what you mean! Placeholder text and also the preview were things I had not considered. I think we may need to add test coverage specifically for the preview. It looks like there's already (a little) coverage for the placeholder text in the new test.

What does the preview look like when using the patch in #83?

jnlar’s picture

StatusFileSize
new19.52 KB

@danflanagan8 here's a screenshot of the preview using patch #83

message block preview from patch #83

Agreed, would another elementTextContains assertion suffice?

// Part 1: Check for Messages placeholder text.
$assert_session->elementTextContains('css', '.layout__region--content', '"Messages" block');
+ $assert_session->elementTextContains('css', '.layout__region--content', 'Placeholder for the "Messages" block');
jnlar’s picture

Status: Needs work » Needs review
StatusFileSize
new8.04 KB
new985 bytes

Added test coverage for preview placeholder text, removed line in comment mentioned by @danflanagan8 in #88

danflanagan8’s picture

StatusFileSize
new7.46 KB
new13.76 KB
new7.95 KB
new7.63 KB
new3.7 KB

Hi @jnlar,
I finally found some time to look at this again and actually think about carefully again. I want to summarize where we are here.

1. The modification to the template is all that is required to allow the Messages block to be managed within LB.
2. The modification to SystemMessagesBlock::build() is a UX enhancement for when "Show content preview" is checked.

I might argue that we should defer #2 to a follow-up. The reason I say that is that it might be worth getting a usability review. It's not obvious to me what is the most desirable UX. Here are the two version of preview UX.

A) With the update to SystemMessagesBlock::build() in #93

"Show content preview" unchecked

"Show content preview" checked, no active status message

"Show content preview" checked, with active status message

B) No modification to SystemMessagesBlock::build()

"Show content preview" unchecked

"Show content preview" checked, no active status message

"Show content preview" checked, with active status message

Both of these approaches allow the Messages block to be managed in LB. Remember, the change to the template is all that's needed to restore contextual filters and the attributes required by LB. Changing or not changing SystemMessagesBlock::build() is all a question of preferred UX.

In my opinion, Approach A is probably more usable, but Approach B gives a more-realistic content preview, which is one of the goals of LB. So I don't know which way to go!

If we were to take Approach A and keep moving with the patch in #93, I would say the test coverage needs to check the "Show content preview" box at some point and confirm that the placeholder text remains. During content preview is where the placeholder text is really supposed to appear. I don't think it's quite a bug that the placeholder text appears even when the content preview box is unchecked, but that's different from how the "Links" field behaves, for example.

I'm going to leave this at NR for now.

jnlar’s picture

hi @danflanagan8,

Thanks for the summary, that'll also help bring newcomers up to speed.

I agree, the issue defined in the IS is not being able to manage the Messages block in LB. It isn't obvious to me whether or not #2 is within the scope of the IS.

I'm for deferring #2 with a follow up, more eyes on this would be good.

In my opinion, Approach A is probably more usable, but Approach B gives a more-realistic content preview, which is one of the goals of LB. So I don't know which way to go!

It does give a more realistic content preview, but you can argue that a realistic preview isn't needed for the Messages block in LB, AFAIK every other preview in LB is using placeholder content.

I don't think it's quite a bug that the placeholder text appears even when the content preview box is unchecked, but that's different from how the "Links" field behaves, for example.

I don't think so either, the olivero theme is responsible for that behaviour. The theme wraps a blocks {{ content }} in a div with the block__content class. When "Show content preview" is unchecked it's display is set to none.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

In addition

Not sure if this one block deserves it's own test instance.

Could this be added to testLayoutBuilderUi

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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.