diff -u b/core/modules/layout_builder/layout_builder.module b/core/modules/layout_builder/layout_builder.module --- b/core/modules/layout_builder/layout_builder.module +++ b/core/modules/layout_builder/layout_builder.module @@ -128,9 +128,11 @@ function layout_builder_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) { if ($display instanceof LayoutEntityDisplayInterface && isset($build['_layout_builder'])) { foreach ($build['_layout_builder'] as $delta => &$section) { - foreach ($section['content'] as $component_uuid => &$component) { - if (isset($component['content']) && isset($component['content']['#theme']) && $component['content']['#theme'] === 'field') { - $component['content']['#view_mode'] = implode('-', ['layout_builder', $delta, $component_uuid]); + if (isset($section['content'])) { + foreach ($section['content'] as $component_uuid => &$component) { + if (isset($component['content']) && isset($component['content']['#theme']) && $component['content']['#theme'] === 'field') { + $component['content']['#view_mode'] = implode('-', ['layout_builder', $delta, $component_uuid]); + } } } } diff -u b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php --- b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php @@ -3,8 +3,8 @@ namespace Drupal\Tests\layout_builder\FunctionalJavascript; use Drupal\Core\Entity\Entity\EntityViewDisplay; +use Drupal\editor\Entity\Editor; use Drupal\FunctionalJavascriptTests\JavascriptTestBase; -use Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait; /** * Tests that Layout Builder functions with Quick Edit. @@ -16,14 +16,16 @@ */ class LayoutBuilderQuickEditTest extends JavascriptTestBase { - use ContextualLinkClickTrait; - /** * {@inheritdoc} */ public static $modules = [ 'block', + 'ckeditor', 'contextual', + 'editor', + 'filter', + 'filter_test', 'layout_builder', 'node', 'quickedit', @@ -38,6 +40,12 @@ $this->createContentType(['type' => 'article']); + $editor = Editor::create([ + 'editor' => 'ckeditor', + 'format' => 'full_html', + ]); + $editor->save(); + $this->drupalLogin($this->drupalCreateUser([ 'access contextual links', 'access toolbar', @@ -45,6 +53,7 @@ 'access content', 'create article content', 'edit any article content', + 'use text format full_html', ])); } @@ -60,7 +69,8 @@ 'title' => 'The node title', 'body' => [ [ - 'value' => 'The node body', + 'value' => '
The node body
', + 'format' => 'full_html', ], ], ]); @@ -83,10 +93,15 @@ $assert_session->elementExists('css', $field_selector); // Wait until Quick Edit loads. - $assert_session->waitForElementVisible('css', $entity_selector . ' .quickedit'); + $condition = "jQuery('" . $entity_selector . " .quickedit').length > 0"; + $this->assertJsCondition($condition, 10000); // Initiate Quick Editing. - $this->clickContextualLink($entity_selector, 'Quick edit'); + $this->getSession()->executeScript("jQuery('.toolbar-icon-menu.is-active').click()"); + $this->click('.contextual-toolbar-tab button'); + $this->click($entity_selector . ' [data-contextual-id] > button'); + $this->click($entity_selector . ' [data-contextual-id] .quickedit > a'); + $this->click($field_selector); $this->assertSession()->assertWaitOnAjaxRequest(); // Trigger an edit with Javascript (this is a "contenteditable" element). @@ -96,7 +111,7 @@ $this->prepareRequest(); // Save the change. - $this->click('.quickedit-button.action-save'); + $this->getSession()->executeScript("jQuery('.quickedit-button.action-save').click()"); $this->assertSession()->assertWaitOnAjaxRequest(); // Assert that the field was re-rendered properly.