Verified Commit 464469c4 authored by godotislate's avatar godotislate
Browse files

Revert "fix: #3328425 CKEditor 5 balloons invisible when CKEditor 5 is used inside a modal"

This reverts commit 59646ce2.
parent 3fae870d
Loading
Loading
Loading
Loading
Loading
+2 −2
Changes for core/modules/ckeditor5/css/ckeditor5.dialog.fix.css: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
.ck-body-wrapper {
  --ck-z-panel: calc(var(--ck-z-default) + 1261);
.ui-dialog ~ .ck-body-wrapper {
  --ck-z-panel: 1261;
}
−7
Changes for core/modules/ckeditor5/tests/modules/ckeditor5_test/ckeditor5_test.routing.yml: 0 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -11,10 +11,3 @@ ckeditor5_test.dialog:
    _controller: '\Drupal\ckeditor5_test\Controller\CKEditor5DialogTestController::testDialog'
  requirements:
    _access: 'TRUE'

ckeditor5_test.dialog_with_editor:
  path: '/ckeditor5_test/dialog_with_editor'
  defaults:
    _form: '\Drupal\ckeditor5_test\Form\CKEditor5DialogTestForm'
  requirements:
    _access: 'TRUE'
+23 −76
Changes for core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5DialogTest.php: 23 added lines, 76 removed lines.
Original line number Diff line number Diff line
@@ -37,82 +37,6 @@ class CKEditor5DialogTest extends CKEditor5TestBase {
   * Tests if CKEditor 5 tooltips can be interacted with in dialogs.
   */
  public function testCKEditor5FocusInTooltipsInDialog(): void {
    $this->createLinkTextFormat();

    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->drupalGet('/ckeditor5_test/dialog');
    $page->clickLink('Add Node');
    $assert_session->waitForElementVisible('css', '[role="dialog"]');
    $assert_session->assertWaitOnAjaxRequest();

    $content_area = $assert_session->waitForElementVisible('css', '.ck-editor__editable');
    // Focus the editable area first.
    $content_area->click();
    // Then press the button to add a link.
    $this->pressEditorButton('Link');

    $link_url = '/ckeditor5_test/dialog';
    $input = $assert_session->waitForElementVisible('css', '.ck-balloon-panel input.ck-input-text');
    // Make sure the input field can have focus and we can type into it.
    $input->setValue($link_url);
    // Save the new link.
    $page->find('xpath', "//button[span[text()='Insert']]")->click();
    // Make sure something was added to the text.
    $this->assertNotEmpty($content_area->getText());
  }

  /**
   * Tests balloons in a dialog opened after an editor exists on the page.
   *
   * CKEditor 5 appends a single shared body wrapper to the page when the first
   * editor is created. If that happens before a jQuery UI dialog is opened,
   * the wrapper is placed before the dialog in the DOM.
   */
  public function testBalloonVisibleInDialogOpenedAfterEditor(): void {
    // Stark does not raise the z-index of jQuery UI dialogs above CKEditor 5
    // balloons, so use a theme that does.
    \Drupal::service('theme_installer')->install(['default_admin']);
    $this->config('system.theme')->set('default', 'default_admin')->save();
    $this->createLinkTextFormat();

    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->drupalGet('/ckeditor5_test/dialog_with_editor');
    $this->waitForEditor();
    $page->clickLink('Add Node');
    $dialog = $assert_session->waitForElementVisible('css', '.ui-dialog');
    $assert_session->assertWaitOnAjaxRequest();

    // Confirm the body wrapper was created before the dialog.
    $this->assertTrue($this->getSession()->evaluateScript(<<<JS
      document.querySelector('.ck-body-wrapper ~ .ui-dialog') !== null
    JS));

    $content_area = $assert_session->waitForElementVisible('css', '.ui-dialog .ck-editor__editable');
    $content_area->click();
    $dialog->find('xpath', "//button[span[text()='Link']]")->click();
    $assert_session->waitForElementVisible('css', '.ck-balloon-panel_visible input.ck-input-text');

    // Make sure the link balloon is the topmost element at its own center
    // point, and is not covered by the dialog. Other visible balloons, such as
    // the "Powered by" balloon, may be positioned off-screen.
    $this->assertSame('balloon', $this->getSession()->evaluateScript(<<<JS
      (function () {
        const balloon = document.querySelector('.ck-balloon-panel_visible input.ck-input-text').closest('.ck-balloon-panel');
        const rect = balloon.getBoundingClientRect();
        const element = document.elementFromPoint(rect.left + rect.width / 2, rect.top + rect.height / 2);
        return balloon.contains(element) ? 'balloon' : (element ? element.className : 'none');
      })()
    JS));
  }

  /**
   * Creates a text format with CKEditor 5 and the link button.
   */
  protected function createLinkTextFormat(): void {
    FilterFormat::create([
      'format' => 'test_format',
      'name' => 'CKEditor 5 with link',
@@ -140,6 +64,29 @@ function (ConstraintViolationInterface $v): string {
        FilterFormat::load('test_format')
      ))
    ));

    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->drupalGet('/ckeditor5_test/dialog');
    $page->clickLink('Add Node');
    $assert_session->waitForElementVisible('css', '[role="dialog"]');
    $assert_session->assertWaitOnAjaxRequest();

    $content_area = $assert_session->waitForElementVisible('css', '.ck-editor__editable');
    // Focus the editable area first.
    $content_area->click();
    // Then press the button to add a link.
    $this->pressEditorButton('Link');

    $link_url = '/ckeditor5_test/dialog';
    $input = $assert_session->waitForElementVisible('css', '.ck-balloon-panel input.ck-input-text');
    // Make sure the input field can have focus and we can type into it.
    $input->setValue($link_url);
    // Save the new link.
    $page->find('xpath', "//button[span[text()='Insert']]")->click();
    // Make sure something was added to the text.
    $this->assertNotEmpty($content_area->getText());
  }

  /**