Skip to content
Snippets Groups Projects
Commit 9c7b7f7b authored by catch's avatar catch
Browse files

Issue #3144010 by danflanagan8, ravi.shankar, tim.plunkett, chrisolof, sorlov:...

Issue #3144010 by danflanagan8, ravi.shankar, tim.plunkett, chrisolof, sorlov: New pseudo-fields cannot be removed, InvalidArgumentException thrown
parent 96dc01cf
No related branches found
No related tags found
6 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!16Draft: Resolve #2081585 "History storage"
......@@ -572,6 +572,7 @@ fieldblock
fieldbody
fieldgroups
fielditem
fieldlayout
fieldlinks
fieldnames
fieldsets
......
......@@ -69,13 +69,16 @@ public function onPrepareLayout(PrepareLayoutEvent $event) {
if ($this->layoutTempstoreRepository->has($section_storage)) {
$this->messenger->addWarning($this->t('You have unsaved changes.'));
}
// If the layout is an override that has not yet been overridden, copy the
// sections from the corresponding default.
elseif ($section_storage instanceof OverridesSectionStorageInterface && !$section_storage->isOverridden()) {
$sections = $section_storage->getDefaultSectionStorage()->getSections();
foreach ($sections as $section) {
$section_storage->appendSection($section);
else {
// If the layout is an override that has not yet been overridden, copy the
// sections from the corresponding default.
if ($section_storage instanceof OverridesSectionStorageInterface && !$section_storage->isOverridden()) {
$sections = $section_storage->getDefaultSectionStorage()->getSections();
foreach ($sections as $section) {
$section_storage->appendSection($section);
}
}
// Add storage to tempstore regardless of what the storage is.
$this->layoutTempstoreRepository->set($section_storage);
}
}
......
name: 'Layout Builder Extra Field test'
type: module
description: 'Support module for testing layout building.'
package: Testing
version: VERSION
<?php
/**
* @file
* Provides hook implementations for Layout Builder tests.
*/
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
/**
* Implements hook_entity_extra_field_info().
*/
function layout_builder_extra_field_test_entity_extra_field_info() {
$extra['node']['bundle_with_section_field']['display']['layout_builder_extra_field_test'] = [
'label' => t('New Extra Field'),
'description' => t('New Extra Field description'),
'weight' => 0,
];
return $extra;
}
/**
* Implements hook_entity_node_view().
*/
function layout_builder_extra_field_test_node_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if ($display->getComponent('layout_builder_extra_field_test')) {
$build['layout_builder_extra_field_test'] = [
'#markup' => 'A new extra field.',
];
}
}
......@@ -240,6 +240,30 @@ public function testAddHighlights() {
$this->assertHighlightNotExists();
}
/**
* Tests removing newly added extra field.
*/
public function testNewExtraField() {
$assert_session = $this->assertSession();
$page = $this->getSession()->getPage();
// At this point layout builder has been enabled for the test content type.
// Install a test module that creates a new extra field then clear cache.
\Drupal::service('module_installer')->install(['layout_builder_extra_field_test']);
\Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
// View the layout and try to remove the new extra field.
$this->drupalGet(static::FIELD_UI_PREFIX . '/display/default/layout');
$assert_session->pageTextContains('New Extra Field');
$this->clickContextualLink('.block-extra-field-blocknodebundle-with-section-fieldlayout-builder-extra-field-test', 'Remove block');
$this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas'));
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextContains('Are you sure you want to remove');
$page->pressButton('Remove');
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextNotContains('New Extra Field');
}
/**
* Confirms the presence of the 'is-layout-builder-highlighted' class.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment