Prevent auto-adding new fields to LB layouts

Created on 25 February 2020, over 4 years ago
Updated 24 June 2024, 5 months ago

Problem/Motivation

Whenever a new field is added to an entity+bundle with LB enabled, a instance of the field is added to the first region of the default LB layout automatically.

This can be quite annoying to say the least, when you have carefully crafted a layout and fields are placed in unexpected positions. Sometimes a field is not mean to be displayed, or perhaps another site builder added a field without remembering to remove the field.

Understandably this is how fields traditionally worked, however visibility of newly added fields is more difficult to detect than simply checking the table within Manage Display tab. For example a field may be invisible, or have no sample value, or the layout/styling may only display the field conditionally.

Steps to reproduce

  1. Install a standard site
  2. Enable LB & add it to the page content type
  3. Add a new field to the page content type and see that it has been added to the layout automatically.

Proposed resolution

Added a new feature flag module to control if new fields are added to the Layout.

Remaining tasks

Create a follow up to enable this module by default.

User interface changes

New fields are no longer added to the entities LB layout.

API changes

A new feature flag module has been added (layout_builder_prevent_adding_new_fields_to_layoutโ€Ž)

Data model changes

Release notes snippet

โœจ Feature request
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Layout builderย  โ†’

Last updated about 11 hours ago

Created by

๐Ÿ‡ฆ๐Ÿ‡บAustralia dpi Perth, Australia

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Pipeline finished with Failed
    9 months ago
    Total: 562s
    #95469
  • Pipeline finished with Failed
    9 months ago
    Total: 488s
    #95497
  • Status changed to Needs work 9 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    Overall looking really good! We have some test failures though.

  • Pipeline finished with Success
    9 months ago
    Total: 615s
    #96213
  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU

    Tests are green, I've responded to the feedback. Happy to hear other options if people disagree. Ready for review :)

  • Status changed to Needs work 9 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Can the issue summary be updated to use the standard issue template.

    Left some comments on the MR.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU

    Flagging that we should add a change record for this too

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU
  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU

    IS updated, CR created.

    Setting this to needs review, there is a couple of open threads that could use some more discussion moving forward.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States DamienMcKenna NH, USA

    Could this be simplified to not add the fields by default at all, and just remove the functionality that does this?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Think thatโ€™s something the sub maintainer could say

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    But I do vote for the tests to be fixed here.

    Unless thereโ€™s history for adding a setting and adding default value to another ticket. That I donโ€™t know

  • Status changed to Needs work 9 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU

    Pushed a commit that sets the new configuration to FALSE for new sites. Lets see how the tests go

  • Pipeline finished with Failed
    9 months ago
    Total: 480s
    #98975
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Not sure if this would fly though. If a bunch of tests do break, maybe in the setup we just set this new configuration to true with a todo to a follow up to cleanup.

    If we do go with the config option and not remove the code out right

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU

    Not sure if this would fly though. If a bunch of tests do break, maybe in the setup we just set this new configuration to true with a todo to a follow up to cleanup.

    I'm a bit lost now. Having it FALSE by default then overriding every LB test to set it to TRUE feels significantly less clean to me then just maintaing the existing behaviour in this issue then changing the default in a follow up. Maybe I'm not understanding something.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Yea now that I read that out loud youโ€™re right

  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU

    Reverted the last commit. Since updating the default value and tests can hopefully be done in a follow up I'm moving this back into needs review

  • Pipeline finished with Success
    9 months ago
    Total: 572s
    #99024
  • Status changed to RTBC 9 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Spoke with @larowlan and we can push the test fixes to a follow up.

    Opened ๐Ÿ“Œ Update layout builder tests and set new config Active

  • Status changed to Needs work 9 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Added some review comments.

  • Pipeline finished with Failed
    8 months ago
    Total: 176s
    #127952
  • Pipeline finished with Success
    8 months ago
    Total: 523s
    #128004
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU

    I've changed the approach of this issue to use a feature flag module rather than configuration. The unresolved threads are no longer relevent, but I'm leaving them open for the moment. Adding the feature flag issue as a related issue.

  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Can the CR be updated with the new approach same for IS.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU
  • Status changed to Needs review 7 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU

    CR & IS updated

  • Status changed to RTBC 7 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Thanks! That clears things up.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Should this be postponed on โœจ Add an API for feature flags Active then as it is using the feature flag module approach but that approach is not yet 100% agreed.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    My understanding was using a sub module flag was a temporary solution till that was worked out

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    @smustgrave looking at the most recent comments on the issue from @catch and @larolwan is looks like each flag is going to be module...

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    A feature flag that disables something feels the wrong way round to me. I think we should install it on existing installs, where users can disable it again if they wish, but not on new installs.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States DamienMcKenna NH, USA

    +1 for longwave's suggestion.

  • Status changed to Postponed 7 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand danielveza Brisbane, AU

    A feature flag that disables something feels the wrong way round to me.

    Yeah good call, I agree with this.

    I think we should install it on existing installs, where users can disable it again if they wish, but not on new installs.

    For the sake of getting this one in quickly we were going to change the default behaviour in a follow up issue. ๐Ÿ“Œ Update layout builder tests and set new config Active However this one is blocked now so maybe we can fit in in here.

    The code that is behind the flag should also be moved to a hook in the feature flag module, if possible?

    As far as I'm aware, the current goal of the feature flag modules is for them to contain no code.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    A feature flag that disables something feels the wrong way round to me

    But this is a "feature" for developers/site builders to stop this annoying behaviour of things being added automatically.

    Honestly I think this behaviour is so disruptive it could almost be considered a bug and just switched off altogether, but that's probably going to delay this even longer.

    I think we should install it on existing installs, where users can disable it again if they wish, but not on new installs.

    Then why not just blanket remove the functionality as per above...?

    When is adding a new field automatically to a bundle's view display actually a good action for the site builder?

    This seems to happen sporadically when view displays are saved via update hooks as well, fields will just get blanket added to the layout for what seems like no reason at all (perhaps they aren't already in the hidden key?)

  • First commit to issue fork.
  • Pipeline finished with Failed
    5 months ago
    #197773
  • Status changed to Needs work 5 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia mstrelan

    We already have an existing feature flag module, already in layout builder, so IMHO we don't need to postpone this on โœจ Add an API for feature flags Active . Worst case we just remove these modules, which we were going to do anyway.

    I've reversed the feature flag module so it provides the old behavior, and new sites get the new behavior by default.

    Setting NW for a update post_update hook to enable the module on existing sites. CR also needs updating.

  • Pipeline finished with Failed
    5 months ago
    Total: 542s
    #197776
  • Pipeline finished with Failed
    5 months ago
    Total: 516s
    #197798
  • Pipeline finished with Failed
    5 months ago
    Total: 560s
    #197808
  • Added a static copy of the latest MR patch.

Production build 0.71.5 2024