Content Not reverting in Layout builder section

Created on 19 March 2021, over 3 years ago
Updated 26 April 2024, 7 months ago

Problem/Motivation

When a Layout Builder node is reverted to a previous revision, it inherits the layout section information of the current revision, not the previous revision.

Steps to reproduce

1. Create a Layout Builder-capable node, with overrides enabled.
2. Add a block of any type to the layout & save.
3. Add a second block of any type to the layout & save (note: a second revision must occur to trigger the problem).
4. Revert to the previous revision.
5. View the node. One block displays (expected). Click "Layout". Sometimes one block displays (expected); sometimes two blocks display (unexpected).
6. Revert to the original revision (this second revert must occur to trigger the problem).
7. View the node. Zero blocks display (expected). Click "Layout". One block displays (unexpected).

Original report

Steps to reproduce from original poster; left for posterity to explain the initial "Needs more info" tag:

1. Edit a hub page, and save the changes
2. The content changes done in step 1 are visible in View mode + in Lay-out builder mode
3. Revert back to previous version, the changes done in step 1 are gone in view mode
4. Activate layout builder, the content does not match whats on the page, it still has the content that you put in during the last time you edited the page i.e. step 1

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Layout builder 

Last updated about 22 hours ago

Created by

🇮🇳India soutams

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

  • 🇳🇿New Zealand john pitcairn

    As a site editor, I would always expect reverting to discard any layout changes. I want the content and layout in sync on revert.

    I cannot imagine a situation where not doing so makes any sense, and I imagine legal might take a fairly dim view of anything otherwise occurring.

  • First commit to issue fork.
  • Pipeline finished with Success
    8 months ago
    Total: 480s
    #113916
  • Status changed to Needs work 8 months ago
  • 🇷🇴Romania amateescu

    I also bumped into this recently, so here's a MR to get things rolling. The approach I've taken is to skip using section storage from the temp store if the revision IDs of the entities don't match.

    What's left to do:
    - in \Drupal\layout_builder\EventSubscriber\PrepareLayout::onPrepareLayout(), detect this situation and change the message from "You have unsaved changes." to something like "You have unsaved changes in a different version of your content. Click here to view it.", where "Click here" would be a link to the current route with a param query appended (enforce_temp_store=1 or something), that would swap the section storage with the one from temp store (the current behavior in HEAD)
    - test coverage

  • 🇮🇳India amarlata

    I followed the all step https://www.drupal.org/project/drupal/issues/3204494#comment-14099699 🐛 Content Not reverting in Layout builder section Active and I am able to reproduce this error in 10.1.8

Production build 0.71.5 2024