Commit a76814b0 authored by catch's avatar catch
Browse files

Issue #3230829 by mohit_aghera, marcvangend, Wim Leers, Kristen Pol:...

Issue #3230829 by mohit_aghera, marcvangend, Wim Leers, Kristen Pol: editor_form_filter_format_form_alter() does not remove "editor_plugin" from form state when needed
parent 5e03f389
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -191,6 +191,7 @@ function editor_form_filter_admin_format_editor_configure($form, FormStateInterf
  if ($editor_value !== NULL) {
    if ($editor_value === '') {
      $form_state->set('editor', FALSE);
      $form_state->set('editor_plugin', NULL);
    }
    elseif (empty($editor) || $editor_value !== $editor->getEditor()) {
      $format = $form_state->getFormObject()->getEntity();
+24 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ class EditorAdminTest extends WebDriverTestBase {
   */
  protected static $modules = [
    'ckeditor',
    'ckeditor5',
  ];

  /**
@@ -66,4 +67,27 @@ public function testEditorSelection() {
    $this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', 'ul.ckeditor-toolbar-group-buttons'));
  }

  /**
   * Tests that editor creation works fine while switching text editor field.
   *
   * The order in which the different editors are selected is significant,
   * because the form state must change accordingly.
   * @see https://www.drupal.org/project/drupal/issues/3230829
   */
  public function testEditorCreation() {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->drupalGet('/admin/config/content/formats/add');
    $page->fillField('name', $this->randomString());
    $page->selectFieldOption('editor[editor]', 'ckeditor5');
    $this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', 'ul.ckeditor5-toolbar-available__buttons'));

    $page->selectFieldOption('editor[editor]', '');
    $assert_session->elementNotExists('css', 'ul.ckeditor-toolbar-group-buttons');

    $page->selectFieldOption('editor[editor]', 'ckeditor');
    $this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', 'ul.ckeditor-toolbar-group-buttons'));
  }

}