Problem/Motivation

Layout builder locks are not workspace-safe: by breaking them in Live you may delete unsaved layout changes performed inside a workspace.

Steps to reproduce

  1. Log in as admin
  2. Enable layout builder on the article content type and allow per-node customization
  3. Create a new article in Live
  4. Create a workspace Test
  5. Edit the article above's layout and swap a couple of blocks without saving
  6. Create an admin-2 user and log in
  7. Switch to Live
  8. Visit the article layout page
  9. Discard the changes
  10. Log back in as admin user and switch back to the Test workspace
  11. Visit the article layout page
  12. Observe

Proposed resolution

Introduce a workspace aware shared tempstore in the workspaces module.

Issue fork drupal-3494997

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

s_leu created an issue. See original summary.

quietone’s picture

Version: 11.1.x-dev » 11.x-dev

Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies.

s_leu’s picture

Issue summary: View changes
amateescu’s picture

Title: Prevent loss of layout changes when breaking lock in different workspace » Prevent loss of layout changes when discarding changes in a different workspace or Live
Category: Task » Bug report
Status: Active » Needs work
Related issues: +#3026957: Provide a generic TempStoreIdentifierInterface that any object can use to better identify itself

I don't think we should take the route of providing a generic workspace-aware temp store implementation, we have #3026957: Provide a generic TempStoreIdentifierInterface that any object can use to better identify itself for that, so let's keep this issue focused on the specific problem we have: LB's temp store needs to be workspace-aware.

Let's decorate the layout_builder.tempstore_repository service with a class that extends LayoutTempstoreRepository, and overrides its getKey() method to append the current workspace ID. Then test coverage needs to be added in \Drupal\Tests\workspaces\FunctionalJavascript\WorkspacesLayoutBuilderIntegrationTest.

amateescu’s picture

Status: Needs work » Reviewed & tested by the community

Looks ready to me!

  • catch committed 8f924c8d on 11.x
    Issue #3494997 by s_leu, amateescu: Prevent loss of layout changes when...
catch’s picture

Status: Reviewed & tested by the community » Fixed

This is tricky but the solution makes sense. I wondered about whether we could add some kind of 'extra keys' container parameter that layout builder could respect, and workspaces could add to, a bit like required render cache contexts, but that feels like it should be its own issue if at all.

Committed/pushed to 11.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.