Problem/Motivation

Layout Builder is on its way to be removed from Drupal core. However Navigation is the modern admin navigation UI enabled in Drupal core now. That depends on Layout Builder. This means the default install of Drupal needs to enable Layout Builder. There is no other core module that depends on Layout Builder.

@berdir summarized this real well:

layout builder is IMHO too heavy and has too many performance implications just to be able to press that button in the backend

Steps to reproduce

Install Drupal. Observe Layout Builder is enabled. This is confusing if you want to use other page layout solutions.

Proposed resolution

  1. Refactor Navigation module so it uses a backwards compatible copy of the layout builder section storage but does not itself require Layout Builder.
  2. Remove the customization UI from Navigation module, so Layout Builder is not even optionally needed by Navigation. (It only needs Layout Discovery).
  3. Add a new Navigation Layout module that allows to customize the navigation bar. This requires Layout Builder currently.
  4. Update tests to require Navigation Layout where testing the UI customization.

New default state of Drupal is no Layout Builder is installed.

The same old, confusing, complicated dedicated Navigation Blocks page only shows up when the Navigation Layout module is enabled (previously this same route/page was built into Navigation module):

Performance improvements

  • Before scenario is main at 2dbbdd8e171 with Layout Builder installed as navigation's dependency.
  • After is the MR branch at bec5c280ce0 with no Layout Builder.
  • Both are fresh Standard installs in the DDEV container, served by PHP's built-in server with opcache on, using MariaDB, with identical content.
  • Render, dynamic page and page caches were disabled (with those caches enabled the per-request time differences mostly go away; the benefits then are the smaller code footprint and memory on every request); b
  • Bootstrap, config and discovery caches were warm.
  • Each measurement is from 5 requests per page, median of results is displayed below.
  • Time is measured server-side inside PHP. Navigation pages are requested as the admin user, the others anonymous.
  • Sample spread is about 0.5 ms, so changes under roughly 3 percent in time are noise (which is most of the cases, so the benefit is most of the cases not in time but memory, although in the node rendering case it was significant time saved!).
Page Time (ms) Peak memory (MB) PHP files loaded DB queries
Navigation: /admin/content 38.7 → 37.9 (−2%) 8.61 → 8.47 (−2%) 1669 → 1619 (−3%) 76 → 76 (0%)
Navigation: /node/6 29.5 → 28.7 (−3%) 7.15 → 6.94 (−3%) 1468 → 1389 (−5%) 60 → 59 (−2%)
Navigation: /user/1 27.8 → 26.8 (−4%) 6.76 → 6.57 (−3%) 1417 → 1338 (−6%) 56 → 56 (0%)
Anonymous: /node/6 14.9 → 13.3 (−11%) 5.88 → 5.72 (−3%) 1361 → 1315 (−3%) 14 → 13 (−7%)
Anonymous: /user/login 10.5 → 10.8 (+3%) 4.76 → 4.67 (−2%) 1194 → 1186 (−1%) 9 → 9 (0%)
Anonymous: /user/password 10.4 → 10.7 (+3%) 4.76 → 4.67 (−2%) 1196 → 1188 (−1%) 9 → 9 (0%)

Takeaways

  • Every request gets lighter whether or not Navigation is displayed: 2 to 3 percent less memory and 8 to 79 fewer PHP files without Layout Builder. But time difference is within error.
  • The largest relative gain is the anonymous node page at 11 percent, where Layout Builder's entity view display class is not added anymore,.

Remaining tasks

Review.

User interface changes

Users need to install the "Navigation Layout" module to customize the Navigation toolbar. Existing site get it enabled automatically on update.

Introduced terminology

None.

API changes

None.

Data model changes

None. However the format used by Navigation is a manual copy of the layout builder storage. The testing included with Navigation Layout is what makes sure the format stays in sync as those tests keep working.

Release notes snippet

The Navigation module does not offer a customization UI by default anymore. The customization UI has been moved to a new Navigation Layout module. This new module is enabled when you update Drupal if you already had Navigation module enabled. The permission for this interface was already called "Configure navigation layout" so the name of it did not change, but the module providing it did.

However if you don't actually need to customize the UI of the Navigation toolbar, this means that can uninstall this module and consequently uninstall Layout Builder module as well, unless you use that for something else too.

LLM disclosure

Original approach was hand crafted. Separation of the Navigation Layout module was LLM assisted with close human review.

Issue fork drupal-3521159

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nod_ created an issue. See original summary.

casey made their first commit to this issue’s fork.

casey’s picture

I've created a MR that removes the dependency on layout_builder while keeping the same config format for navigation.block_layout. The dependency is removed by simply calling the Layout and Block plugin managers directly.

The UI is still to be replaced. I only emptied navigation LayoutForm and added a new route "navigation.layout" to replace "layout_builder.navigation.view".

gábor hojtsy’s picture

Status: Active » Needs review

This currently moves down the dependency to layout_discovery. Is that a module that stays around in core? (There are a lot more criteria of course, but it is also not depended on by Experience Builder or UI Suite that I could find at least).

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

catch’s picture

@gábor hojtsy layout_discovery provides the layout plugin manager service definition.

#3483307: New `ComponentSource`: `Layout`, to allow for a Layout Builder-to-Canvas migration doesn't depend on the layout_discovery service but it does depend on the same layout plugin manager class that the service uses (which is in Drupal\Core).

So I think that even if we eventually deprecate the layout_discovery module, the layout plugin manager itself will need to exist for quite a long time to support the just in time layout builder -> xb upgrade path. That could mean that navigation module ends up adding it's own version of the layout plugin manager or something like that - but it should be a relatively small incremental step to remove that dependency if/when we get to that point.

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.

berdir made their first commit to this issue’s fork.

berdir’s picture

Rebasing this and trying to move this forward.

The MR currently removes the layout builder integration completely. This seems like a pretty hard change to land as we'd then for now would not have a UI at all.

How about we split this so that we make the layout_builder integration optional just for the UI? My goal for moving this forward is to avoid having to depend on layout_builder at runtime. Because layout_builder comes with significant performance implications right now and has its hooks deep in all kinds of places.

The UI page would then just display a message to enable layout_builder to customize it.

berdir’s picture

I reverted quite a bit of changes. Navigation works without layout builder being enabled. The backend shows a message to enable layout builder if you don't have it enabled. To make it work, I essentially had to do two non-trivial/annoying things:

* Copy the code of the two traits from layout builder, because missing traits is a parse error and those form classes are loaded during route building. We could possibly maintain two different form classes and dynamically register them, but even the existence of a form class is going to be trouble with route attribute discovery and so on.
* Hardcode the route definition including all the magic bits that layout_builder adds to make things work.

Additionally to the existing duplications like the schema definition. I think that's acceptable as an intermediate step for #3521155: Remove Layout Builder dependency for the UI of Navigation admin config, still use Layout Builder for backend and rendering.

Still struggling with some test fails that I can't reproduce or fail differently for me.

plopesc’s picture

Thank you for stepping into this.

Checked the code and looks really promising. Regarding how to deal with the configuration page, maybe a temporary navigation_ui module that enables the access to that page might simplify the things a bit?

godotislate’s picture

maybe a temporary navigation_ui module that enables the access to that page might simplify the things a bit?

Do you mean like a feature flag module? Except in this case the module would have the layout builder dependency?

I think that might be a good idea.

godotislate’s picture

Since we're changing navigation config schema here, does it make sense to address or keep in mind changes that we'll need for #3587499: Navigation stores plugin configuration with dependencies in a simple config object?

godotislate’s picture

Sounds like in #3521155: Remove Layout Builder dependency for the UI of Navigation admin config, still use Layout Builder for backend and rendering, the thinking might be to move the UI to a separate module navigation_ui that eventually moves to contrib, so it probably makes sense to land this close to as is now and then do a follow up to move relevant code including tests to the new module.

gábor hojtsy’s picture

I like this too! We need to define if the customization UI is at all 80% use case assuming contrib can still provide that :)

pameeela’s picture

I agree that the customisation UI does not need to be in core. Drupal CMS does modify the layout but this is in a recipe so the UI is never needed. There will be sites that want to modify it, but certainly not very often, and it could be done locally for example so you don't need all of the dependencies in production ever.

godotislate’s picture

Merged main and resolved conflicts (hopefully correctly). @berdir mentioned some outstanding test failures in #12, and there are test failures now. I have not checked if they are the same, but I might look into the test failures later.

godotislate’s picture

berdir’s picture

Looked a bit at the tests, the UI really is broken right now and doesn't load. Instead of trying to fix that, if we agree that we want to move forward with a navigation_ui module, then I'll refactor that and go back to using the layout builder traits there, that will hopefully fix that.

gábor hojtsy’s picture

@berdir: let us know when the MR is again ready for review or if you need helping hands :)

quietone made their first commit to this issue’s fork.

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review

This is waiting on a decision about having a navigation_ui module. See #21. Changing to needs review for that discussion/decision.

And I did a rebase.

gábor hojtsy’s picture

I think moving the Layout Builder related code out to its own UI module is the best choice. The UI is very awkward anyway (last I tried a couple months back and nothing changed in the meantime) and Layout Builder is on its way out of core.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

gábor hojtsy’s picture

Status: Needs work » Needs review

I used some LLM assistance to rebase and start resolving some new fails. The moved code sections for shortcuts especially needed to be taken care of.

gábor hojtsy’s picture

Now it all passes green again, so I'm looking at decoupling the LB integration to its own module :)

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new98 bytes

The Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

gábor hojtsy’s picture

Title: Remove Layout Builder dependency for the config and rendering of the Navigation sidebar » Remove Layout Builder dependency from Navigation. Add Navigation UI module to integrate with Layout Builder.
Issue summary: View changes
Status: Needs work » Needs review

Update title and issue summary.

MR is green.

I think this is done-done unless we want to install the Navigation UI automatically on a site update (which I think is debatable). The release notes snippet explains you can even uninstall Layout Builder if you only used for this. (I don't think we have a way to automatically detect that situation though).

Please try and review. :)

gábor hojtsy’s picture

Issue summary: View changes
StatusFileSize
new292.6 KB
new325.98 KB

Added screenshots from my local setup.

gábor hojtsy’s picture

Issue summary: View changes

Adding this priceless quote from @berdir to the issue summary:

layout builder is IMHO too heavy and has too many performance implications just to be able to press that button in the backend

longwave’s picture

"Navigation UI" is a confusing name to me, because the primary purpose of the Navigation module is already to provide a UI. Even the issue summary says "Navigation is the modern admin navigation UI", using the same name in a different context.

Is "Navigation Layout Builder" a better name, seeing as it combines those two things?

pameeela’s picture

Agree re: naming, but "Navigation Layout Builder" also feels misleading because you were never really building a layout, just placing and reordering menu blocks (you can't choose columns etc which to me is what building a layout really means).

What about just "Navigation Layout" (consistent with Block layout) or "Navigation Manager"?

gábor hojtsy’s picture

I agree navigation UI was very confusing but I did not have better ideas. Navigation Layout is simple and very good IMHO :) Did that.

gábor hojtsy’s picture

Title: Remove Layout Builder dependency from Navigation. Add Navigation UI module to integrate with Layout Builder. » Remove Layout Builder dependency from Navigation. Move existing integration with Layout Builder to new Navigation Layout module.

Renaming issue following module rename. Also making it clear that this is the existing code split, its not new code :)

gábor hojtsy’s picture

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new98 bytes

The Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

kim.pepper’s picture

The IS says:

Layout Builder is on its way to be removed from Drupal core

Is this true? Where is the issue that made that decision?

acbramley made their first commit to this issue’s fork.

acbramley’s picture

Status: Needs work » Needs review

Rebased with a lot less changes since shortcut has been removed.

Used our new fancy performance test update environment variable to regenerate the metrics too :)

gábor hojtsy’s picture

@kim.pepper: I did not find where we documented that, so opened #3619180: [policy, no patch] Move Layout Builder module to contrib now. However that was at the same discussion at DrupalCon Vienna where we discussed also removing the block UI, see #3555047: Add a way to ship block placement statically (will be useful when block UI is removed). Basically the idea is that Drupal core would not have a UI to structure pages and you would pick whichever you wanted, be if layout builder or canvas or paragraphs or display builder. Eg in #3521155: Remove Layout Builder dependency for the UI of Navigation admin config, still use Layout Builder for backend and rendering @catch writes It seems likely that this won't be the last blocker to deprecating layout builder.

We also need an issue about manage display which is the third layout builder in core on the side of Layout Builder and blocks, but I don't 100% remember what was the direction discussed there, maybe @catch does?

quietone’s picture

Title: Remove Layout Builder dependency from Navigation. Move existing integration with Layout Builder to new Navigation Layout module. » Add Navigation Layout module to remove dependency on Layout Builder

Just tweaking the title

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

acbramley’s picture

Status: Needs work » Needs review
csakiistvan’s picture

✅ Tested and works — MR !11972. A do fresh Standard install no longer enables Layout Builder (only Layout Discovery), and the navigation sidebar and top bar render fine without it. With Navigation Layout uninstalled the "Navigation blocks" page is gone and its route 404s; installing Navigation Layout brings Layout Builder back in as a dependency and restores that page, where placing a menu block and saving it showed up in the sidebar right away. Navigation Layout can then be uninstalled on its own without taking Navigation with it, and no errors were logged in any of the three states. Based on this I would suggest RTBC.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new98 bytes

The Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

gábor hojtsy’s picture

Title: Add Navigation Layout module to remove dependency on Layout Builder » Move Layout Builder editing UI from Navigation to dedicated new Navigation Layout module to remove runtime dependency
Issue summary: View changes
Status: Needs work » Needs review

Make title clearer as people were taken by surprise that its proposing to add a new layout tool. Its just moving code around.

Updating issue summary for current module name. Also mention upgrade path and permissions.

All concerns on the issue are resolved so should be ready for review again :)

gábor hojtsy’s picture

Title: Move Layout Builder editing UI from Navigation to dedicated new Navigation Layout module to remove runtime dependency » Move editing UI as-is from Navigation to dedicated new Navigation Layout module to remove runtime Layout Builder dependency

Even more clearer title. Sorry for ping-ponging on this.

gábor hojtsy’s picture

Issue summary: View changes
Issue tags: +Performance

Added extensive performance measurements. Tagging for that too, since that is a key motivation for this issue.

gábor hojtsy’s picture

Issue summary: View changes

Formatting.

gábor hojtsy’s picture

Issue summary: View changes

bluegeek9 made their first commit to this issue’s fork.

bluegeek9 changed the visibility of the branch 11.x to hidden.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new98 bytes

The Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

csakiistvan’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

gábor hojtsy’s picture

Status: Needs work » Needs review
csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

Assigned: csakiistvan » Unassigned

@gábor hojtsy I tested again and it looks good and same as on #46 previous state. Based on this I would suggest RTBC.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

finnsky’s picture

Great initiative!
I'll rebase and test.

finnsky’s picture

I tested various layout change scenarios—everything works as expected!
+1 for RTBC - frontend is good! Thank you!

finnsky’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

anybody’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: +no-needs-review-bot

Re-confirming RTBC!

godotislate’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -11.5.0 release priority +12.1.0 release priority

There's a merge conflict in the MR, so back to NW.

timohuisman made their first commit to this issue’s fork.

timohuisman’s picture

Status: Needs work » Needs review

I rebased the MR on main.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, well done! Back to RTBC!