Add the notion of a 'configured layout builder block' to solve a number of content-editor and performance pain points

Created on 8 June 2023, about 1 year ago
Updated 9 May 2024, about 2 months ago

Problem/Motivation

There are currently a number of pain points with Layout Builder and how it interacts with the block plugin system as follows:

Proposed resolution

  • Per #3043330-95: Reduce the number of field blocks created for entities (possibly to zero) Add a 'legacy mode' settings flag to layout builder.
  • Enable this for existing sites.
  • With this flag on, a new config entity 'configured layout builder block' is available. This encapsulates
    • the functionality of layout builder browser (block order, block icon, configurable block category, configurable block label)
    • functionality of layout builder restrictions (which regions and sections it can be used in. At present Layout builder restrictions manages this on the view mode configuration but this is overwhelming and often results in a lot of merge conflicts for config YML files. Flipping the restriction management from being on the view display to on the block will reduce this pain and also simplify the UI of adding restrictions. The current UI in contrib is a series of expanding/collapsing details elements and modals to allow for all the possible blocks and sections.
  • Be sure to store the regions/section data in a way that would allow onDependencyRemoval to work (E.g. key sections/layouts by provider) and allow reacting to modules providing layouts being disabled.
  • Create a configured layout builder block map service, like we have for field map, that would be performant to query which blocks are available for which sections and regions given an entity context.
  • When configuring these 'configured layout builder block' config entities, allow the site builder to preconfigure and hide block config options from the content editor - this would allow preconfiguring the new block entity-field block from above to set formatter options - or for example configuring a views block
  • These 'configured layout builder block' config entities would also support adding the same field twice. E.g the example from above a 'short post date' and a 'long post date' could be preconfigured by the site builder.
  • Having a pre-defined set of 'configured layout builder block' entities would allow front-end teams to work with a known set of options to ensure that everything available had an appropriate front-end representation.

See also 📌 [PP-1] Move away from derivatives for FieldBlock and instead use block settings Postponed for more steps to improve this for field blocks

Remaining tasks

  • ✅ Discuss the pain points with product managers (@lauriii, @gabor, @ckrina)
  • ✅ Discuss the proposed resolution with subsystem maintainer (@tim.plunkett)
  • Discuss the solution with maintainers of LB restrictions and LB browser
  • Implement the solution with test coverage
  • Reviews

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Active

Version

11.0 🔥

Component
Layout builder 

Last updated about 2 hours ago

Created by

🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

  • Issue created by @larowlan
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
  • 🇺🇸United States tim.plunkett Philadelphia
  • First commit to issue fork.
  • last update about 1 year ago
    Custom Commands Failed
  • @acbramley opened merge request.
  • First commit to issue fork.
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Discussed this with @DanielVeza and we agreed to reduce the scope somewhat.

    The configurable block to replace the existing field block work can be done separately as that's going to present some major UX challenges that we'll likely need a few rounds of testing on.

    Added 📌 [PP-1] Move away from derivatives for FieldBlock and instead use block settings Postponed to split that out into its own separate issue and refined the scope/proposed resolution here.

  • 🇳🇿New Zealand John Pitcairn

    I've just had to implement something for a client - the goal was to (almost) completely hide the complex content field block label/formatter settings from site editors who are using layout builder on a single entity, while still allowing site builders to configure defaults for those settings.

    We wound up with a custom field block plugin that takes its ::build() formatter settings from a dedicated 'layout_builder' view mode on the entity, and does not add elements for those in ::form etc. That works nicely and re-uses existing mechanisms.

    It would have been great to take those formatter settings from configured display settings on the current view mode, but baked-in core assumptions make that hard:

    For site builders, it would be no great leap if they could just configure defaults where they normally would for the entity display, and maybe there is a permission or other toggle associated with layout builder block configuration that either:

    • Hides the configuration and uses those existing defaults, or
    • Shows the configuration, populated by those defaults
  • 🇳🇿New Zealand John Pitcairn

    What happens if somebody turns that flag off on a site with legacy layout builder content?

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    The expectation is that if you wanted the new mode, you'd configure all the blocks for the new approach, then toggle off legacy mode.

  • 🇳🇿New Zealand John Pitcairn

    OK so legacy mode means "keep existing layout builder block instance config", and the new configured layout builder block is available to configure and use whether that is checked or not? The issue summary implies that's only available if legacy mode is checked.

    Can sites keep using existing editor-configured blocks, while adding and using some preconfigured blocks? I can see this being a slow transition for sites with limited resources but lots of existing content.

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Yeah that's the plan.

    When you switch off legacy mode, the list of blocks shown in the 'choose block' list will draw from the preconfigured ones only.

    The content will remain as is. 📌 [PP-1] Move away from derivatives for FieldBlock and instead use block settings Postponed will likely have a more interesting migration path.

  • 🇳🇿New Zealand John Pitcairn

    OK and when you switch off legacy mode, existing legacy block instances will remain in the layout, but you wont be able to add new legacy blocks. Gotcha.

  • First commit to issue fork.
  • 🇫🇮Finland lauriii Finland

    I discussed this issue with @catch and got inspired to try if we could try to create a runtime BC layer for the block derivatives. I started writing a PoC for the field blocks because they had more complex derivatives. It's not pretty for sure but wanted to post it here for visibility.

  • 🇬🇧United Kingdom catch

    #18 is very clever indeed, I can't think through all the implications yet, but if we can drop the derivatives and shim the new plugin, and then also encourage people to change their layout config, that would be amazing - can fix both the performance and UX issues much, much quicker that way.

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    #18 very neat

  • 🇧🇪Belgium Wim Leers Ghent 🇧🇪🇪🇺

    So … should we continue #18? 😄

  • 🇬🇧United Kingdom catch

    Yes it would be ideal - being able to just drop the existing plugin on existing sites (or at minimum have a killswitch for it which any site can safely turn on) makes the entire process easier, so it's just... all the other bits to do here.

Production build 0.69.0 2024