Layout Builder - Add a refresh layout defaults feature

Created on 1 February 2023, almost 2 years ago

Problem/Motivation

When Layout Builder default layouts are amended, there is no easy way to go back to existing content and "update" the layout to match the new layout.

The current solution requires reverting and updating all content manually and being careful to sync all the default layout sections and blocks to avoid this issue. As the amount of content grows and the desire to rework layouts increases, it creates a major problem for Content Managers to maintain the content.

Steps to reproduce

First, create a content type and enable Layout builder in the default display view mode. After go to manage layout and save the layout including some default sections and blocks.

Next, create new content that include the default layout, and you can include extra sections and block to the layout content.

After the new content with the layout changes is saved, go to the content type to update the default layout applying any change, like adding a new section and/or block.

Finally, go to the previous content you created and edit its layout. You will see there is no way to see or include the new changes you made in the default layout without adding them manually.

Proposed resolution

In the layout edit form, there is the layout overrides buttons sections that allow to apply additional actions to the existing content layout. The proposal is to include a new button named as "Refresh layout default" which can be next to the existing "Revert to defaults" button, as shown in the screenshot below.

Moreover, the new button can redirect to a form asking confirmation of the action to the user.

Remaining tasks


2. Open a merge request to review and manual test of the functionality.
3. Create automated tests that validates the new feature in layout builder module.

User interface changes

A new button should be displayed in the edit layout overrides form, as shown in the screenshot example below:

The button should behave similarly to the existing "Revert to defaults" feature, and redirect to a new confirmation form with the option to Refresh or Cancel the action. It should also inform that once the action is confirmed it cannot be undone.

API changes

In order to include the new "Refresh layout defaults" button, it will require the following code changes and additions in the layout builder module:




- Include the unit test for "Refresh to layout defaults" button in \Drupal\Tests\layout_builder\Unit\OverridesSectionStorageTest::testBuildRoutes().
- Include the functional test for "Refresh to layout defaults" button in \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testLayoutBuilderUi().
- Include the functional test for "Refresh to layout defaults" button in \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testLayoutBuilderUiFullViewMode().

Data model changes

N/A

Release notes snippet

N/A

✨ Feature request
Status

Active

Version

10.0 ✨

Component
Layout builderΒ  β†’

Last updated about 13 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom technoveltyco

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024