Custom Blocks with Layout Builder Enabled No Longer Use Front End Theme

Created on 26 February 2024, 9 months ago
Updated 8 May 2024, 7 months ago

Problem/Motivation

When using Layout Builder for a block_content display, the admin theme is now used for any overrides when it should be the front end theme.

This is a regression that has been introduced recently, most likely by [#3320855].

Steps to reproduce

  • Install a fresh Drupal standard site
  • Enable Layout Builder
  • Add a new custom block
  • Enable Layout Builder & Layout Builder overrides for the block display
  • Create an instance of the new block
  • Edit the layout for the block you just created
  • Verify you are in the admin theme, not front end theme

Proposed resolution

Ensure the front end theme is always used when editing a block content layout.

Remaining tasks

RTBC
Merge

User interface changes

The front end theme will be used when editing a block content layout.

API changes

N/A

Data model changes

N/A

Release notes snippet

NA

Before/After screenshots

Before - In admin theme

After - In front end theme

Original report

When editing a block that has layout builder enabled you no longer edit the block in the front end theme.
You now use the admin theme.

Ex. /admin/content/block/1/layout - now uses admin theme whereas in the past it was frontend theme.
on the contrary, managing the layout display for all blocks of a type: /admin/structure/block-content/manage/{block_name}/display/full/layout still uses the frontend theme.

I think the preferred method is to always use the frontend theme, unless you are using a module like: https://www.drupal.org/project/layout_builder_admin_theme β†’

is this an issue anywhere? i can't find it. thanks!

πŸ› Bug report
Status

Fixed

Version

10.3 ✨

Component
Layout builderΒ  β†’

Last updated about 4 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States bradallenfisher

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @bradallenfisher
  • πŸ‡ΊπŸ‡ΈUnited States bradallenfisher
  • First commit to issue fork.
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    DanielVeza β†’ changed the visibility of the branch 3423920-custom-blocks-with to hidden.

  • Status changed to Needs review 8 months ago
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Left some comments on the MR - thanks!

  • Pipeline finished with Success
    8 months ago
    Total: 1618s
    #140384
  • Pipeline finished with Success
    8 months ago
    Total: 659s
    #140408
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    Addressed the feedback. I've moved the new functionality to the Layout Builder module.

    I was going to wrap the new code in a moduleExists('block_content'), but since Layout Builder is already getting a dependency on block_content in πŸ“Œ Hidden dependency on block_content in layout_builder Needs work and adding this route doesn't cause any hard without the block_content module I think it's fine to keep in.

    The main reason why I went against this approach is that it means we would need to add the ModuleHandler dependency to LayoutBuilderRoutes, just to then deprecate and remove it after πŸ“Œ Hidden dependency on block_content in layout_builder Needs work has been commited.

  • Pipeline finished with Canceled
    8 months ago
    Total: 503s
    #140416
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    The main reason why I went against this approach is that it means we would need to add the ModuleHandler dependency to LayoutBuilderRoutes, just to then deprecate and remove it after

    Makes sense - the presence of the route in the collection signals the module exist anyway right?

  • Pipeline finished with Success
    8 months ago
    Total: 568s
    #140419
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    Ah yes you're correct. We check if that route exists before we do anything. That esentially acts as a moduleExists('block_content') anyway :)

  • Status changed to Needs work 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Seems @acbramley already did a review.

    But landing on the ticket noticed the issue summary could use an update, would be helpful to use the standard issue template. UI changes before/after screenshots, proposed solution, etc.

  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU
  • Status changed to Needs review 8 months ago
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    MR feedback addressed, IS updated.

    Ready for review again

  • Pipeline finished with Success
    8 months ago
    Total: 1781s
    #141144
  • Status changed to RTBC 8 months ago
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Changes look great, IS reads well. Tried to run the test only job but it is currently broken https://git.drupalcode.org/issue/drupal-3423920/-/jobs/1273985

    I think this is good to go now regardless, small uber nit on the MR that could be applied on commit.

  • Pipeline finished with Success
    8 months ago
    Total: 662s
    #141166
  • Status changed to Needs work 8 months ago
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Need to fix the test file and class name, I had run the test only job and it passed. Got very confused and posted in #gitlab thinking the job itself was broken. Thanks to @fjgarlin for seeing the name was invalid.

  • Status changed to Needs review 8 months ago
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    πŸ€¦β€β™‚οΈ Renamed the test file

  • Pipeline finished with Success
    8 months ago
    Total: 6169s
    #142226
  • Status changed to RTBC 8 months ago
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Test only run failed as expected, good to go!

  • Status changed to Needs work 8 months ago
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Should we be fixing this here or in \Drupal\layout_builder\Routing\LayoutBuilderRoutesTrait::buildLayoutRoutes() or in \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::buildRoutes()... like should we have a generic fix here for all entity types or something specific for content blocks?

    For example: \Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage::buildRoutes() does $options['_admin_route'] = FALSE; prior to calling LayoutBuilderRoutesTrait::buildLayoutRoutes() - why is OverridesSectionStorage::buildRoutes() not doing the same?

  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    I did have the thought while I was doing this that it was a little odd to be writing a specific override for one entity type.

    I don't have the historical context on why OverridesSectionStorage::buildRoutes doesn't set _admin_route to FALSE, so I'm unsure if thats an oversight or a choice that was made.

    Either way, I've reworked the solution to disable the _admin_route in OverridesSectionStorage::buildRoutes and renamed the test to be more generic.

  • Pipeline finished with Failed
    7 months ago
    Total: 748s
    #144451
  • Pipeline finished with Success
    7 months ago
    Total: 628s
    #144473
  • Status changed to Needs review 7 months ago
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    Tests green again

  • Status changed to RTBC 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Can confirm the issue following the steps in the issue summary
    Applying the MR does resolve the issue of layout builder using admin theme

    Screenshots are near identical to the issue summary but here's a fresh set.

    Before

    After

    • catch β†’ committed 1fe3e7be on 10.3.x
      Issue #3423920 by DanielVeza, smustgrave, acbramley, bradallenfisher,...
    • catch β†’ committed 38d72469 on 11.x
      Issue #3423920 by DanielVeza, smustgrave, acbramley, bradallenfisher,...
  • Status changed to Fixed 7 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    This looks good to me, couldn't find anything to complain about.

    Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks!

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

Production build 0.71.5 2024