Stale values can be displayed by the Layout Builder UI but are saved correctly

Created on 26 February 2019, about 6 years ago
Updated 21 March 2023, about 2 years ago

Problem/Motivation

🐛 Saving Layout override will revert other field values to their values when the Layout was started. Fixed fixes the actual data loss, this issue is about how the UI *implies* there is data loss.
Steps to reproduce

  1. Allow custom layout overrides on articles
  2. Create an article with body value "original"
  3. Save article
  4. Open article /layout page
  5. update article at /edit page. set body to "updated"
  6. Open article /layout page
  7. Article body is still "original"
  8. Save layout
  9. Article body is "updated"

Proposed resolution

TBD

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs review

Version

10.1

Component
Layout builder 

Last updated 2 days ago

Created by

🇺🇸United States tim.plunkett Philadelphia

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

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

  • Usability

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

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.

  • 🇧🇪Belgium stefdewa

    Updated test to use 'stark' instead of 'classy' as default theme.

  • Status changed to Needs work about 2 years ago
  • 🇺🇸United States luke.leber Pennsylvania
    +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/FieldValuesTest.php
    @@ -0,0 +1,119 @@
    +  protected static $modules = [
    +    'layout_builder',
    +    'block',
    +    'node',
    +  ];
    

    We should probably enable the field_ui module here as well. I believe that 4 years ago, field_ui was required by layout builder, but that has since been decoupled.

    This should fix the test failure, I believe :-)

    I can confirm that #53 fixes the issue on 9.4.12. Here's a dumbed down condition that was reported to us:

    Say there are three states:

    • Draft
    • Pending
    • Published

    and various transitions:

    • Draft -> Draft
    • Draft -> Pending
    • Pending -> Pending
    • Pending -> Draft
    • Pending -> Published
    • Published -> Draft

    and an "Author" only has access to Draft -> Draft, Draft -> Pending, and Published -> Draft.

    1. A piece of content is in "Pending" state, thus an Author has no available transitions, and the edit / layout routes will return 403
    2. A layout override is started, but not saved (only existing in the tempstore)
    3. The content is moved from "Pending" to "Draft"
    4. Authors will now have access to the Edit tab, but not the Layout tab until changes are discarded!

    Following applying #53, authors have access to the Edit and Layout tabs appropriately.

    Sorry for the long-winded comment -- I can vouch for RTBC once the test fail is resolved.

  • Status changed to Needs review about 2 years ago
  • Adding field_ui as mentioned in #55

  • Status changed to Needs work about 2 years ago
  • 🇺🇸United States luke.leber Pennsylvania
    +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/FieldValuesTest.php
    @@ -0,0 +1,120 @@
    +    $links_block = $assert_session->elementExists('css', '.block-extra-field-blocknodebundle-for-testing-fieldslinks');
    

    Do'h! I think this class used to be added by the Classy theme! This test is now using Stark after #53!

    A different CSS selector will have to be used -- I'm not sure off the top of my head exactly what that would be though.

  • 🇮🇳India ranjith_kumar_k_u Kerala

    Updated the CSS selector, and there is no specific CSS class on the Body field block in the Stark theme

    <div data-layout-content-preview-placeholder-label="&quot;Body&quot; field" class="js-layout-builder-block layout-builder-block contextual-region" data-layout-block-uuid="3d159177-0c9a-4e57-bf47-6b5cce1e3fa3" data-layout-builder-highlight-id="3d159177-0c9a-4e57-bf47-6b5cce1e3fa3" draggable="false">

    That is why I updated the code like this

    $links_block = $page->findAll('css', ".layout__region--content > .layout-builder-block");
        // The second block is the body field so that is why $links_block[1].
        $links_block_uuid = $links_block[1]->getAttribute('data-layout-block-uuid');

    The other test failures from the file "core/modules/layout_builder/tests/src/FunctionalJavascript/FieldValuesTest.php" are because of the following issue
    Allow field blocks to display the configuration label when set in Layout Builder 🐛 Allow field blocks to display the configuration label when set in Layout Builder Fixed

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update almost 2 years ago
    29,283 pass, 2 fail
  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States bnjmnm Ann Arbor, MI

    Tests should typically be passing before an issue is set to "Needs Review", especially since it looks like the failure is related to the changes being made.

    There are occasional exceptions, and in those cases there should be an explanation as to why it's getting set to "Needs Review" despite failing tests.

  • last update almost 2 years ago
    29,442 pass
  • last update almost 2 years ago
    29,560 pass
  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India ranjith_kumar_k_u Kerala

    Hi, the last patch was failing tests due to the following issue https://www.drupal.org/project/drupal/issues/3039185 🐛 Allow field blocks to display the configuration label when set in Layout Builder Fixed , now that issue has been fixed on 10.1x and 11x, So here last patch tests are passing now.

  • last update almost 2 years ago
    29,442 pass
  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States smustgrave

    Issue summary is incomplete. If that could be updated please.

  • First commit to issue fork.
  • Pipeline finished with Failed
    about 1 year ago
    Total: 192s
    #118571
  • Pipeline finished with Success
    about 1 year ago
    Total: 618s
    #118574
  • Pipeline finished with Failed
    about 1 year ago
    Total: 559s
    #118594
  • Pipeline finished with Failed
    about 1 year ago
    Total: 171s
    #118611
  • Pipeline finished with Failed
    about 1 year ago
    Total: 487s
    #118936
  • Pipeline finished with Canceled
    about 1 year ago
    Total: 31s
    #118949
  • Pipeline finished with Failed
    about 1 year ago
    Total: 478s
    #118951
  • Status changed to Needs review about 1 year ago
  • 🇺🇦Ukraine Taran2L Lviv

    So, I've converted #59 to a MR, then fixed a few nitpicks.

    My idea of modernizing it a bit is not working as expected, so I've given up on that

    Please review

  • Pipeline finished with Canceled
    about 1 year ago
    #119035
  • Pipeline finished with Failed
    about 1 year ago
    Total: 494s
    #119036
  • Pipeline finished with Failed
    about 1 year ago
    Total: 643s
    #119065
  • Pipeline finished with Success
    about 1 year ago
    Total: 541s
    #119102
  • Status changed to Needs work about 1 year ago
  • 🇺🇸United States smustgrave

    Issue summary looks good thanks!

    Left some comments on the MR, mostly small stuff

    Ran test-only feature

    There was 1 error:
    1) Drupal\Tests\layout_builder\FunctionalJavascript\FieldValuesTest::testLayoutBuilderUiDoesNotShowStaleEntityFieldValues
    Behat\Mink\Exception\ResponseTextException: The text "The changed value" was not found anywhere in the text of the current page.
    /builds/issue/drupal-3035992/vendor/behat/mink/src/WebAssert.php:907
    /builds/issue/drupal-3035992/vendor/behat/mink/src/WebAssert.php:293
    /builds/issue/drupal-3035992/core/tests/Drupal/Tests/WebAssert.php:956
    /builds/issue/drupal-3035992/core/modules/layout_builder/tests/src/FunctionalJavascript/FieldValuesTest.php:96
    /builds/issue/drupal-3035992/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
    ERRORS!
    Tests: 1, Assertions: 7, Errors: 1.
    

    So coverage appears to be there.

    Looks super close!

  • Pipeline finished with Success
    about 1 year ago
    Total: 635s
    #119455
  • Pipeline finished with Success
    about 1 year ago
    Total: 572s
    #119500
  • Status changed to Needs review about 1 year ago
  • Status changed to RTBC about 1 year ago
  • 🇺🇸United States smustgrave

    Feedback appears to be addressed

    Confirmed the issue described in the issue summary has been resolved

    #67 mention the test coverage is there

  • Status changed to Needs work about 1 year ago
  • 🇺🇸United States tim.plunkett Philadelphia

    Left some suggestions for nits, but also raised a few points that need to be addressed.

  • Pipeline finished with Failed
    about 1 year ago
    Total: 602s
    #120407
  • Pipeline finished with Canceled
    about 1 year ago
    #120423
  • Pipeline finished with Success
    about 1 year ago
    Total: 571s
    #120424
  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. 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.

  • Status changed to Needs review about 1 year ago
  • 🇺🇦Ukraine Taran2L Lviv

    Bot seems to be wrong, latest MR passes everything and it contains latest changes from the core

  • Status changed to Needs work about 1 year ago
  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. 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.

  • Status changed to Needs review about 1 year ago
  • 🇺🇸United States smustgrave

    So the review bot has been temporarily turned off as a bug is look at.

    But appears the feedback has been addressed but will leave in review for @tim.plunkett to agree.

  • Pipeline finished with Canceled
    about 1 year ago
    Total: 6s
    #123133
  • Pipeline finished with Success
    about 1 year ago
    Total: 488s
    #123134
  • 🇺🇦Ukraine Taran2L Lviv

    So, there is one unresolved threadm everything else has been addressed afaik.

  • 🇺🇸United States smustgrave

    I've also seen using layout_builder__layout as a check has been discouraged before, see 🐛 PageTitle block is non-functional when not handled directly by \Drupal\block\Plugin\DisplayVariant\BlockPageVariant Postponed . Though the solution I came up with over there not too sure about, hoping @Tim.plunkett has some better trick.

  • 🇺🇸United States smustgrave

    @Tim.plunkett do you have a different preferred approach or good to continue with what's there?

  • Assigned to tim.plunkett
  • Status changed to Needs work 12 months ago
  • 🇺🇸United States tim.plunkett Philadelphia

    I will try to look between now and the end of DrupalCon. For now, I'd consider this NW for finding a better way

  • 🇺🇸United States jastraat

    Just to confirm, this is still an issue with the latest release of Drupal 11.

  • Pipeline finished with Failed
    6 days ago
    Total: 197s
    #469409
  • Pipeline finished with Success
    6 days ago
    Total: 781s
    #469422
  • Pipeline finished with Canceled
    6 days ago
    Total: 73s
    #469444
  • Pipeline finished with Success
    6 days ago
    Total: 882s
    #469446
  • 🇺🇸United States jastraat

    I rebased on Drupal 11 and moved the new entity update hook to the hook class with the rest. I'd like to throw this back out for review -

  • 🇺🇸United States jasongose

    This works for me :)

  • Pipeline finished with Success
    about 12 hours ago
    Total: 445s
    #474072
Production build 0.71.5 2024