diff --git a/core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php b/core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php index ef154f1b2b2..db38b1203e5 100644 --- a/core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/OverridesSectionStorage.php @@ -187,7 +187,9 @@ class OverridesSectionStorage extends SectionStorageBase implements ContainerFac * {@inheritdoc} */ public function getDefaultSectionStorage() { - return LayoutBuilderEntityViewDisplay::collectRenderDisplay($this->getEntity(), 'default'); + // @todo Expand to work for all view modes in + // https://www.drupal.org/node/2907413. + return LayoutBuilderEntityViewDisplay::collectRenderDisplay($this->getEntity(), 'full'); } /** diff --git a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php index 4dc9a85d0db..a78e9eeeb79 100644 --- a/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php +++ b/core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php @@ -256,4 +256,67 @@ class LayoutBuilderTest extends BrowserTestBase { $assert_session->elementNotExists('css', '.block.menu--mymenu'); } + /** + * Tests the interaction between full and default view modes. + * + * @see \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::getDefaultSectionStorage() + */ + public function testLayoutBuilderUiFullViewMode() { + $assert_session = $this->assertSession(); + $page = $this->getSession()->getPage(); + + $this->drupalLogin($this->drupalCreateUser([ + 'configure any layout', + 'administer node display', + 'administer node fields', + ])); + + $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field'; + // Allow overrides for the layout. + $this->drupalPostForm("$field_ui_prefix/display/default", ['layout[allow_custom]' => TRUE], 'Save'); + + // Customize the default view mode. + $this->drupalGet("$field_ui_prefix/display-layout/default"); + $this->clickLink('Add Block'); + $this->clickLink('Powered by Drupal'); + $page->fillField('settings[label]', 'This is the default view mode'); + $page->checkField('settings[label_display]'); + $page->pressButton('Add Block'); + $assert_session->pageTextContains('This is the default view mode'); + $this->clickLink('Save Layout'); + + // The default view mode is used for both the node display and layout UI. + $this->drupalGet('node/1'); + $assert_session->pageTextContains('This is the default view mode'); + $this->drupalGet('node/1/layout'); + $assert_session->pageTextContains('This is the default view mode'); + $this->clickLink('Cancel Layout'); + + // Enable the full view mode and customize it. + $this->drupalPostForm("$field_ui_prefix/display/default", ['display_modes_custom[full]' => TRUE], 'Save'); + $this->drupalGet("$field_ui_prefix/display-layout/full"); + $this->clickLink('Add Block'); + $this->clickLink('Powered by Drupal'); + $page->fillField('settings[label]', 'This is the full view mode'); + $page->checkField('settings[label_display]'); + $page->pressButton('Add Block'); + $assert_session->pageTextContains('This is the full view mode'); + $this->clickLink('Save Layout'); + + // The full view mode is now used for both the node display and layout UI. + $this->drupalGet('node/1'); + $assert_session->pageTextContains('This is the full view mode'); + $this->drupalGet('node/1/layout'); + $assert_session->pageTextContains('This is the full view mode'); + $this->clickLink('Cancel Layout'); + + // Disable the full view mode, the default should be used again. + $this->drupalPostForm("$field_ui_prefix/display/default", ['display_modes_custom[full]' => FALSE], 'Save'); + $this->drupalGet('node/1'); + $assert_session->pageTextContains('This is the default view mode'); + $this->drupalGet('node/1/layout'); + $assert_session->pageTextContains('This is the default view mode'); + $this->clickLink('Cancel Layout'); + } + }