Problem/Motivation

With a clean install and enabling the admin theme as default you cannot remove blocks seperately then fully removing the section.
So if you make a mistake by adding a wrong block you need to start over again because you cannot edit or remove blocks separately.

1. Go to https://simplytest.me or install a new Drupal 8.6.1 instance locally
2. Make Seven your default theme
2. Enable layout_builder
3. Create a content type
4. Enable layout_builder on the newly created content type by view display -> Default -> Check "Use Layout Builder" and
"Allow each content item to have its layout customized."
5. Go to manage display and "Manage Layout"
6. Add 2 blocks and try to remove 1 of the 2 blocks.

Proposed resolution

-

Original report by Lennard Westerveld

CommentFileSizeAuthor
#43 interdiff.txt1.57 KBlauriii
#41 3005403-2-41.patch8.34 KBalexpott
#41 35-41-interdiff.txt2.15 KBalexpott
#35 interdiff.txt8.57 KBrensingh99
#35 3005403-35.patch8.56 KBrensingh99
#35 claro_test_result.png9.02 KBrensingh99
#35 seven_test_result.png11.6 KBrensingh99
#35 claro.png19.88 KBrensingh99
#35 seven_theme.png10.82 KBrensingh99
#34 3005403-34.patch16.77 KBalexpott
#34 16-34-interdiff.txt4.49 KBalexpott
#32 php_unit_test_result.png10.11 KBrensingh99
#32 code_sniffer_result.png17.22 KBrensingh99
#32 after_apply_patch.png13.97 KBrensingh99
#32 before_apply_patch.png16.7 KBrensingh99
#16 3005403-16.patch4.66 KBalexpott
#16 3005403-16.test-only.patch3.54 KBalexpott
#16 5-16-interdiff.txt3.86 KBalexpott
#5 3005403-core-layout_builder-5.patch947 bytesLennard Westerveld
#2 3005403-core-layout_builder-2.patch927 bytesLennard Westerveld
ScreenshotRecord-2018-10-09T14-41-20-080Z.mp418.01 MBLennard Westerveld
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Lennard Westerveld created an issue. See original summary.

longwave’s picture

Please note there is no need to run patches on every single test environment, just one test is sufficient for most cases. Normally you should just set the issue to "Needs review" and the relevant test will be selected automatically.

Lennard Westerveld’s picture

Oh, awesome I didn't now that feature.

Lennard Westerveld’s picture

Created a patch based on the /core/themes path instead of /themes.

Lennard Westerveld’s picture

Status: Active » Needs review
volkswagenchick’s picture

Issue tags: +badcamp 2018

tagging for badcamp 2018

tim.plunkett’s picture

Title: Cannot delete or edit a block that is placed in a section of the layout_builder. » Cannot delete or edit a block that is placed in a section of the layout_builder
Component: layout_builder.module » Seven theme

Not sure about hardcoding knowledge of modules into themes, but the patch looks like it would work.

Note that in the original designs, there was never a plan to use LB with admin themes.

greggles’s picture

Thanks for your work on this, Lennard Westerveld!

The use case where this is helpful for me is a site where there are many entities, some of which are user-facing and some are admin-facing. The admin-facing entities (so far) are using a sub theme that has Seven as its base theme. This works great for the admin folks - they get a clean, dense, distraction-free page. I ran into trouble when using the Layout Builder for these entities and this patch has solved that problem.

I can see what you're saying, Tim, about the theme being overly integrated with the layout module. At the same time, it seems that the Seven theme is already closely coupled to contextual links here, so perhaps that is OK?

jwineichen’s picture

I was so confused by this because I have Admin Theme installed and set it to /admin/*. So it was forcing the admin theme for the layout builder interface. I was like, "What do you mean you weren't supposed to use layout builder with admin themes? You use the admin theme to edit the layout!" Everything makes a lot more sense now.

GoZ’s picture

I have the same issue using seven or adminimal_theme by default.

Patch #5 fix it. Thanks @Lennard Westerveld

volkswagenchick’s picture

Issue tags: +drupalnorth2019

Tagging for DrupalNorth 2019

bisonbleu’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #5 works, thanks @Lennard Westerveld.

Using Drupal 8.7.3 combined with menu_item_extras and menu_block.

Based on comments, I'm setting to RTBC.
If you think differently, feel free to change.

PCate’s picture

Patch #5 worked for me as well.

Using 8.7.3 with simple_megamenu

alexpott’s picture

The docblock needs updating as * Disables contextual links for all blocks. is now wrong. It feels like this is something that should be tested. Especially as we're about to add a new admin theme. Here's a patch that adds a test for Seven theme and its seven_preprocess_block().

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

Patch needs review because we now add a test.

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

Status: Needs review » Needs work

The last submitted patch, 16: 3005403-16.patch, failed testing. View results

jibran’s picture

Test looks good.

+++ b/core/tests/Drupal/FunctionalTests/Theme/SevenTest.php
@@ -0,0 +1,115 @@
+    $page = $this->getSession()->getPage();
...
+    $page->fillField('settings[label]', 'This is the label');
+    $page->checkField('settings[label_display]');
+    $page->pressButton('Add block');

I think we need to refresh the page object as it is not up to date with the latest response.

alexpott’s picture

Version: 8.7.x-dev » 8.8.x-dev
Status: Needs work » Needs review

@jibran I run tests locally before submitting a patch so that's not the issue. The problem is that between 8.7.x and 8.8.x the text of the button changed from Add Block to Add block :(

Rerunning tests against 8.8.x

g089h515r806’s picture

Patch #16 works.

volkswagenchick’s picture

Issue tags: +dcco2019

Tagging for DrupalCamp Colorado 2019 (Sunday August 4)

xjm’s picture

Priority: Normal » Major
xjm’s picture

This issue also affects Claro. #3079738: Add Claro administration theme to core

One thing we should consider here is the scenario where a theme is used as both the backend and frontend theme. @gabesullice and @zrpnr were testing a site with that setup and were completely stumped by this bug. If the theme is used in both backend and frontend, do we really want to hide the contextual links blocks from paths that are frontend paths?

Also, do we actually still want to stick with #2487025: Remove contextual links in Seven in the first place?

I think we can keep the scope of this issue to fixing Layout Builder since that's a major-almost-critical bug, and open a followup to discuss the broader picture of what we need to do with this hook in the future.

lauriii’s picture

Issue tags: +Needs manual testing

Not sure about hardcoding knowledge of modules into themes, but the patch looks like it would work.

I don't think there's anything wrong about hardcoding knowledge of modules into themes, as long as they still work without those modules. In fact, a lot of existing code in themes is already specific to modules, for example bartik_preprocess_node is specific to node module.

Would be great to see some screenshots how contextual links work in Seven. Since contextual links have been more or less always disabled, we haven't been actively testing them.

volkswagenchick’s picture

Issue tags: +badcamp2019

Tagging for badcamp2019, thanks! (October 2-5)

Kris77’s picture

Patch in #16 work for me too.

Thanks @alexpott

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.

capysara’s picture

Patch in #16 applies and works for 8.9.

rensingh99’s picture

Assigned: Unassigned » rensingh99
rensingh99’s picture

Hi,

I have reviewed and manually tested below are my updates:

1) I created "layout_builder_test" content type
2) I enabled the "layout_builder" module for layout_builder_test content type
3) Screenshot before applying the patch
before_apply_patch
4) Screenshot after applying the patch
after_apply_patch

Worked as designed

I am also attaching screenshot for code sniffer result and PHP unit test result which passed.

Thank you
Ren

rensingh99’s picture

Assigned: rensingh99 » Unassigned
Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
4.49 KB
16.77 KB

Fixing Claro as well - plus adding a test for Claro.

rensingh99’s picture

Hi,

I just reroll the patch and it's working great.

Bellow is my output screenshot of Edit "Layout Builder" page for claro as well as seven

1). Seven Theme

2). Claro Theme

Bellow is my output screenshot of test results for claro as well as seven.

1). Seven Theme

2). Claro Theme

Thanks,
Ren

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

We still need follow-up for #25. 🙏

greggles’s picture

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

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs followup, -Needs manual testing
+++ b/core/tests/Drupal/FunctionalTests/Theme/SevenLayoutBuilderTest.php
@@ -0,0 +1,120 @@
+      // Note that Seven is not supported as a frontend theme but it is enabled
+      // here to test layout builder.

Have we actually documented somewhere that Seven is not supported as a frontend theme?

lauriii’s picture

Status: Needs review » Reviewed & tested by the community

Discussed with @alexpott and we agreed to remove the comment mentioned in #38 to not hold this fix to a major bug on that. This can be done on commit.

lauriii’s picture

Status: Reviewed & tested by the community » Needs review
  1. +++ b/core/tests/Drupal/FunctionalTests/Theme/ClaroLayoutBuilderTest.php
    @@ -0,0 +1,110 @@
    +    // Ensure other blocks do not have contextual links.
    +    $assert_session->elementNotExists('css', 'div.block-page-title-block.contextual-region div[data-contextual-id]');
    

    We're not placing the page title block on the Claro test at all. I think we might have a false positive because we are not asserting if the page title exists.

  2. +++ b/core/tests/Drupal/FunctionalTests/Theme/SevenLayoutBuilderTest.php
    @@ -0,0 +1,120 @@
    +  protected $defaultTheme = 'seven';
    ...
    +    $this->assertTrue($this->container->get('theme_installer')->install(['seven']));
    +    $this->container->get('config.factory')
    +      ->getEditable('system.theme')
    ...
    +      // here to test layout builder.
    +      ->set('default', 'seven')
    +      ->set('admin', 'seven')
    +      ->save();
    

    Do we need this with the $defaultTheme property?

alexpott’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
2.15 KB
8.34 KB

Thanks for the review @lauriii

RE #40.1 Well Claro ships with block config so it doesn't need to place the block BUT we can improve the test by making a positive assertion that the expected block is present - since having a negative assertion on it's own if very prevalent to false positives in the future.

#40.2 - yep this can all be removed which addresses #38 too.

Since these are test only improvements I'm going to set this to RTBC.

  • lauriii committed 221ec16 on 9.0.x
    Issue #3005403 by alexpott, Lennard Westerveld, rensingh99, lauriii, xjm...
lauriii’s picture

Version: 8.9.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
FileSize
1.57 KB

I made minor coding standards improvement. Interdiff attached.

Committed 221ec16 and pushed to 9.0.x and 8.9.x. Thanks!

This is a major bug fix with low risk so I'm leaving this open to be cherry-picked to 8.8.x once the freeze is over.

  • lauriii committed f7b2381 on 8.9.x
    Issue #3005403 by alexpott, Lennard Westerveld, rensingh99, lauriii, xjm...

  • lauriii committed 39ea073 on 8.8.x
    Issue #3005403 by alexpott, Lennard Westerveld, rensingh99, lauriii, xjm...
lauriii’s picture

Status: Patch (to be ported) » Fixed

Cherry-picked to 8.8.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

kumar_kundan’s picture

I Am still facing this issue while i have all the patches mentioned here.

GarChris’s picture

My issue had nothing to do with Seven Theme, but I'm leaving this comment because this page came up high on search for "Cannot edit or delete block in layout_builder". My issue was related to the Layout Builder UX. See issue and patch at https://www.drupal.org/project/lb_ux/issues/3116402