diff --git a/core/modules/layout_builder/src/Form/AddBlockForm.php b/core/modules/layout_builder/src/Form/AddBlockForm.php index 14d9646f9e..24af14b150 100644 --- a/core/modules/layout_builder/src/Form/AddBlockForm.php +++ b/core/modules/layout_builder/src/Form/AddBlockForm.php @@ -47,8 +47,16 @@ protected function submitLabel() { * The form array. */ public function buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, $delta = NULL, $region = NULL, $plugin_id = NULL) { - $component = new SectionComponent($this->uuidGenerator->generate(), $region, ['id' => $plugin_id]); - $section_storage->getSection($delta)->appendComponent($component); + $component_key = $this->getFormId() . '_component'; + + $component = $form_state->get($component_key); + if (empty($component)) { + $component = new SectionComponent($this->uuidGenerator->generate(), $region, ['id' => $plugin_id]); + $form_state->set($component_key, $component); + + $section_storage->getSection($delta)->appendComponent($component); + } + return $this->doBuildForm($form, $form_state, $section_storage, $delta, $component); }