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 @@ -159,7 +159,7 @@ // If the entity is displayed within a Layout Builder block and the current // route is in the Layout Builder UI, then remove all contextual link // placeholders. - if ($display instanceof LayoutBuilderEntityViewDisplay && strpos($route_name, 'layout_builder.') === 0) { + if ($display instanceof LayoutBuilderEntityViewDisplay && str_starts_with($route_name, 'layout_builder.')) { unset($build['#contextual_links']); } } @@ -224,8 +224,8 @@ // 3. A layout override field is present. // @todo Remove instanceof FieldableEntityInterface check in // https://www.drupal.org/node/3046216 - if (strpos($route_name, 'layout_builder.') !== 0 && $entity instanceof FieldableEntityInterface && $entity->hasField('layout_builder__layout')) { - // If an entity's field values change and it also has a layout override in + if ($route_name && !str_starts_with($route_name, 'layout_builder.') && $entity instanceof FieldableEntityInterface && $entity->hasField('layout_builder__layout')) { + // If an entity's field values change, and it also has a layout override in // the tempstore, the tempstore must be updated to reflect those new // values. /** @var \Drupal\layout_builder\LayoutOverrideFieldHelper $override_field_helper */ diff -u b/core/modules/layout_builder/tests/src/FunctionalJavascript/FieldValuesTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/FieldValuesTest.php --- b/core/modules/layout_builder/tests/src/FunctionalJavascript/FieldValuesTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/FieldValuesTest.php @@ -53,11 +53,8 @@ ])); // Enable layout builder. - $this->drupalPostForm( - static::FIELD_UI_PREFIX . '/display/default', - ['layout[enabled]' => TRUE], - 'Save' - ); + $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default'); + $this->submitForm(['layout[enabled]' => TRUE], 'Save'); $this->createNode([ 'type' => 'bundle_for_testing_fields', @@ -76,11 +73,8 @@ $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); - $this->drupalPostForm( - static::FIELD_UI_PREFIX . '/display/default', - ['layout[allow_custom]' => TRUE], - 'Save' - ); + $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default'); + $this->submitForm(['layout[allow_custom]' => TRUE], 'Save'); $this->drupalGet('node/1'); $assert_session->pageTextContains('The initial value'); @@ -100,11 +94,9 @@ $assert_session->pageTextContains($overridden_label); $changed_body_value = 'The changed value'; - $this->drupalPostForm( - 'node/1/edit', - ['body[0][value]' => $changed_body_value], - 'Save' - ); + + $this->drupalGet('node/1/edit'); + $this->submitForm(['body[0][value]' => $changed_body_value], 'Save'); // Confirm that changes to a field are seen in the Layout UI without // altering a layout's changes in the tempstore.