Dynamically instantiated CKEditor 5 instance's toolbar occludes Drupal's toolbar if it has focus and the form is part of paragraph

Created on 15 March 2023, almost 2 years ago
Updated 1 February 2024, 11 months ago

Problem/Motivation

The usability of ckeditor5 is degraded when editing a WYSIWYG field added to the form of a paragraph (paragraph module) and these conditions apply:

1. the field is part of a sub-form that is added dynamically to the form page (for example when adding a paragraph to a node page)
2. the ckeditor5 contains a big amount of text
3. when scrolling down on a page which has ckeditor5 active in this kind of form, if the viewport scrolls past where ckeditor5's toolbar would no longer be visible it is detached and made to stick to the top of the viewport. This conflicts with the standard toolbar so that the toolbar is partially hidden.

This seems ad edge case of this solved issue: #3259380: CKEditor 5's toolbar occludes Drupal's toolbar if and only if CKEditor 5 has focus

Steps to reproduce

1. enable ckeditor5 module, add a format that uses it
1. install the contrib paragraph module
2. create a paragraph type that includes a text-long field that uses ckeditor5
3. create a content type with a paragraph field, allow the paragraph type created in 2. to be added to the content type
4. create a new node of the content type
5. add a paragraph of the type defined in 2. to the page
6. add a big amount of text, so that the ckeditor window gets longer than the viewport
7. scroll up, observe the toolbar overlapping with the drupal toolbar

🐛 Bug report
Status

Active

Version

9.5

Component
CKEditor 5 

Last updated 2 days ago

Created by

🇫🇮Finland vermario

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • JavaScript

    Affects the content, performance, or handling of Javascript.

Sign in to follow issues

Comments & Activities

  • Issue created by @vermario
  • Status changed to Postponed: needs info over 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Odd, this was reported and fixed a very long time ago, in #3259380: CKEditor 5's toolbar occludes Drupal's toolbar if and only if CKEditor 5 has focus ! What version of Drupal core are you using?

    Another related issue: 🐛 Ensure that CKEditor 5 toolbar always remains visible in dialog *and* renders below dialog title bar (if it exists) Closed: outdated .

  • 🇫🇮Finland vermario

    hi! I am using Drupal core 9.5.5

    The issue you are linking to is indeed fixed, and if I use a content type that has for example the body field, that is on the page when the page loads, the issue does not happen.

    This ticket is however about the cases there a field with ckeditor5 is not initially there when the page loads, because it is in a paragraph form field which is initially collapsed. When the paragraph "subform" is opened, then ckeditor appears, and my suspicion is that the fix added as part of #3259380 is unable to fix the issue in this different context.

  • Status changed to Active over 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Aha! Clarified scope, now it makes sense: it's a new edge case. Thanks 😊

  • 🇺🇸United States alison

    Hi! So I reproduced this issue in Drupal 9.5.10, and in Drupal 10.1, under slightly different circumstances -- but I think the key detail is still valid: CKEditor isn't there when the page initially loads.

    FYI: These steps are based on when I reproduced the issue in a plain DrupalPod workspace with Drupal 10.1 and the Umami install profile.

    1. On a Drupal 9.5.10 or Drupal 10.1 site -- ...
    2. Go to Text formats and editors: /en/admin/config/content/formats
    3. Drag "Plain text" to the top of the list, so it'll be the default/active text format when you create a new node.
    4. Create a new Basic page.
    5. On the body field, switch the text format to "Basic HTML"
    6. Put a ton of content in the body field, so the CKEditor field is taller than the viewport.
    7. Behold: CKEditor toolbar is "on top of" the admin menu.

    Attached: Screenshots of this behavior, in Drupal 10.1 and Drupal 9.5.10.

    -------

    @vermario Do you have the admin_toolbar module enabled? -- to be clear, I reproduced the issue we're talking about here with and without the admin_toolbar module. BUT, when CKEditor 5 is present when the page initially loads, I have another issue (maybe unrelated!!): The CKEditor 5 sticky toolbar obscures admin_toolbar drop-down menus ( example ). Again, I really, really don't know if it's the same issue, but, just wondering if you happen to have that issue, too (if you have admin_toolbar).

  • 🇺🇸United States mariacha1

    I can confirm that changing the Text Format via the dropdown makes the ckeditor5 toolbar on 10.2.2. I'm attaching a gif of the behavior.

    I've also shown in that gif that resizing the page or toggling the menu to the sidebar fixes the issue, so I tried to debug a little but the js is beyond me. The best I could understand is that the "drupalViewportOffsetChange" event is triggered by both of those things (resizing, swapping the admin toolbar orientation), but it must not be triggered when you swap editors. I also found that the top of the CKEditor toolbar is set using "editor.ui.viewportOffset" which is supposed to be at 79 but ends up being at 0 when you swap editors. So maybe something isn't being initialized correctly during editor swap?

Production build 0.71.5 2024