Problem/Motivation
Modal dialogs (such as the link dialog) in the CKEditor 5 WYSIWYG toolbar do not activate when CKEditor is within a modal. This may be a regression of #3274937: Get CKEditor 5 to work in (modal) dialogs
Steps to reproduce
Simple steps to reproduce quickly:
- Install ckeditor_test test module
- Go to /ckeditor5_test/dialog
- Click add node
- Click on the link toolbar icon
Real world example to reproduce:
- Create a content type (eg: Article) with a Media field that references the Image media type
- Add a rich text field to the Image media entity type (eg: Caption) and configure it to use a text format that supports links and uses CKEditor 5.
- Add a new node (eg Article) and add a new Image.
- Try to link text in the rich text field.

Cause
This is a CSS z-index issue. The z-index of the CK5 balloon modals is 1000. While the z-index of the jQueryUI Dialog modals is 1260. The z-index needs to be set to a minimum of 1261.
Proposed resolution
Fix the bug that is preventing text from being linked.
Remaining tasks
Identify cause of bugSubmit merge requestTest- Get maintainer approval
User interface changes
Balloons from CK Editor are now visible within dialogs, pop-ups, and modal windows.
Introduced terminology
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
Balloons from CK Editor are now visible within dialogs, pop-ups, and modal windows.
| Comment | File | Size | Author |
|---|---|---|---|
| #64 | 3328425-64-drupal-core-11.3.5-ckeditor5-ballon.patch | 501 bytes | dench0 |
| #63 | 3328425-drupal-core-11.3.3-ckeditor5-ballon.patch | 1.74 KB | arthur.baghdasar |
| #60 | 3328425-60-drupal-core-10.4.6-ckeditor5-ballon.patch | 1.69 KB | naveenvalecha |
| #56 | footnotes.png | 27.36 KB | scott_euser |
| #41 | 2024-07-23_16-36.png | 65.69 KB | scott_euser |
Issue fork drupal-3328425
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
cilefen commentedAre there browser console errors?
Comment #3
cedeweyI just tried again with Google Chrome's Inspector console running and no errors came up.
Comment #4
mherchelVerified that the problem exists. Bumping this to Major.
Got the following error in the JS console (not sure its related)
Comment #5
mherchelDid more debugging on this. TL;DR, it's a
z-indexissue. Updating issue summary.Comment #6
mherchelMore digging. This was originally fixed in #3274937: Get CKEditor 5 to work in (modal) dialogs. Somehow it regressed.
Comment #7
mherchelSo the problem is that the fix in #3274937: Get CKEditor 5 to work in (modal) dialogs assumed that the
.ui-dialogdiv willalways occur before the.ck-body-wrapperin the DOM. This isn't always the case, which leads to this issue.The fix for this is to either globally raise the
z-indexto 1261 or, we need to have a jQueryUI add a CSS class to thebodyelement so we can use that in our selector.Comment #8
mherchelTalked with @lauriii on a minisprint today, and he agreed changing the global value of the CKEditor balloon to 1261 is the path forward.
Comment #9
mherchelHere's some initial work on changing the global value, however, it's not quite ready.
An issue can up during testing where if you have a CKEditor instance not in a modal, and then trigger a balloon panel (which is the correct terminology I learned), and then you open up a modal, the balloon panel will still be visible.
We should close all balloon panels on
focusoutIMHO. I'm not too familiar with CK5's internals so not quite sure how to proceed.Comment #10
finex commentedHi, I'm also experiencing this bug with paragraphs popup: the "add link" z-index needs to be greater than 1260.
Comment #11
hudriModern CSS can easily query forwards and backwards. When the initial, unobtrusive solution was
than the opposite direction is also possible, with exaclty the same CSS specifity
(The
:isis not strictly necessary, but it turns the 2nd half of the selector into a "forgiving" selector that doesn't kill the entire rule if a browser does not support:hasyet)All relevant browsers except Firefox support :has, and Firefox should support it within first half of 2023
Comment #12
realityloop commentedComment #14
realityloop commentedComment #15
realityloop commentedComment #16
realityloop commentedPS: My merge request still suffers from the problem that @mherchel mentioned in #9
Comment #17
carolpettirossi commentedI want to add that I'm facing this issue as well in another scenario.
I'm trying do add a link to a CKEditor that is inside a Layout Builder Modal
Comment #18
wim leersClarifying issue title.
Comment #19
abhisekmazumdarThe patch in #9 works and displays the pop-up, but it does not allow typing in the input box.
Comment #20
scott_euser commentedI could type in the input box fine testing this out, perhaps you could provide steps to reproduce that @abhisekmazumdar?
@mherchel for #9 I could not reproduce in my scenario but perhaps could consider applying the z-index within :focus-within in some way here rather than a likely complicated CKE5/JS solution?
Comment #21
kensae commentedI can confirm the patch in #9 works for me and typing is possible. This patch also solves the following issue for me: https://www.drupal.org/project/drupal/issues/3351603
Comment #22
attheshow commentedPatch in #9 is working for us.
Comment #23
ruslan piskarovMR !4288 introduced in #16 works. Thank you very much. Didn't try #9.
Comment #24
nchase commentedPatch #16 works for me. Now the link pop-up is showing over a modal layout paragraph.
Comment #25
tlo405 commentedLatest MR is working for me.Edit: Scratch that...this patch appears to break in layout builder now. Before this patch, I was seeing no issues with these dialogs in layout builder.
Comment #26
finex commentedHi, after updating to Drupal 10.3, the CkEditor inside Layout Builder iFrame Modal works fine and I don't need anymore this patch.
Comment #27
gcbRe-roll of the MR fix against 10.3.x.
Comment #28
hudriAll patches and MR do no longer work in v10.3.0
#26 seems not relevant to this issue due I-Frame. The issue here is about CKeditor ballons in Ajax modals inside a simple < div >.
#27 does not work, the property
--ck-z-modalis no longer used in v10.3.0. The relevant property was renamed to--ck-z-panelComment #29
hudriComment #30
hudriComment #31
greenskin commentedPatch from #27 applies clean for me, Drupal 10.3.0.
Comment #32
philyUsing Drupal 10.3.1, I confirm @hudri at comment 28:
So patch#27 updated to use --ck-z-panel (instead of --ck-z-modal or using both for retrocompatibility) will be OK.
Comment #34
scott_euser commentedThe current approach in the MR also does not work; it assumes we are in Claro, but for example even the test in core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5DialogTest.php is using Olivero, so the issue recurs.
At that same automated test URL you can also see other variables used as well, like panel, not just modal, and having the same issue. Screenshot once updated MR is applied:
Comment #35
scott_euser commentedAttempted to add test coverage to core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5DialogTest.php after the
$this->pressEditorButton('Link');but does not seem like either of these are true tests for visibility unfortunately:Would be good to get a review on that + advice whether true visibility/z-index is testable within what we have available in Drupal.
This is by the way still an issue in 11.x and easily reproduced by:
Updated issue summary to standard template.
Comment #39
scott_euser commentedComment #40
scott_euser commentedOkay actually has to be 1262 (1 higher) otherwise balloon within modal within modal does not work. Tested this by:
This is the same approach used by 'ai' module + 'ckeditor5_embedded_content' module, and I would guess others as well. I expect you could reproduce with Core alone by adding a cke5 formatted text field to a media entity then loading that within media insert of e.g. article body field.
Did some tidy up of branches/patches. If anyone needs patch, please follow the documentation to download a patch locally. You can also use the 'show' buttons to show links just for yourself to old patch files, but please don't post new ones. Thanks!
Comment #41
scott_euser commentedScreenshot of balloon within modal within modal:
Comment #42
cecrs commentedFor those commenters that couldn't click in the input box after applying the patch, the toolbar might be at fault. My particular issue is after I open a modal from the toolbar. If I close the modal and reload the page, the input field works fine. (I'm using a custom module called account modal that opens the user/edit in a modal, including the link in the toolbar user menu.)
Comment #43
scott_euser commentedCould you make a screencast of that perhaps? Maybe unrelated but good to understand the issue better; I guess if it can't be focused perhaps something else is in the way or maybe some other js overriding focus
Comment #44
gareth.poole commented"So patch#27 updated to use --ck-z-panel (instead of --ck-z-modal or using both for retrocompatibility) will be OK."
Confirming --ck-z-panel works in 10.3.1
Comment #45
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #46
scott_euser commentedHiding patch. Please download patches locally instead as per documentation. Helps avoid confusion + things like the above with the bot reviewing the patch instead of the merge request.
Comment #47
nchase commentedThe patch in #44 works for me in Drupal 10.3.1 with Layout Paragraphs.
Comment #48
smustgrave commentedLooking at remaining tasks looks like the open one is to get maintainer approval.
Comment #49
smustgrave commentedElevating
Comment #50
naveenvalechaHere's the patch for drupal core 10.3.5 which we're using on one of our website
Comment #51
alanoakden commentedI just want to add a comment in here for anyone still dealing with CKeditor 4 and seeing this issue that may need a fix sooner than moving to CKeditor 5 and applying this patch (nevertheless, you should really be using CKeditor 5 and indeed I will look to get the project I'm working on to move to this)
It appears CKeditor 4 doesn't have the ui-dialog class at all, this seems pretty essential to make things work (nevermind if you then see the issues mentioned above)
In my case, i found simply adding `ui-dialog` as a class to the div that also has `cke_reset_all cke_dialog_container` classes already, made all functionality click into gear and work as expected.
I have a custom admin subtheme theme added to the project, i did a pre-process hook in the .theme file to add a library on the relevant content type node-edit pages
And then wrote JS similar to this (couldn't see a way to add the class via patch or similar).
This JS observes the page and once CKeditor inserts its dialog divs, it adds the 'ui-dialog' class
Of course, don't forget to add the JS file reference in your subtheme libraries file
Comment #52
smustgrave commentedMR of upping the z-index seems pretty straight forward. Going to mark to get in front of framework managers.
Comment #53
alexpottI've added some comments to address on the MR.
Comment #54
scott_euser commentedThanks for the feedback. I applied the comments and retested as per #40 and all works fine. Changing to 9999 for the line suggested to match the cke5 dll doesn't hurt of course.
Comment #55
scott_euser commentedMerge conflicts, needs update
Comment #56
scott_euser commentedComment #57
smustgrave commentedGoing to go on a limb and leaning on testing in #56 that feedback has been addressed
Comment #58
nod_Given that this was a regression and the actual implementation had to change based on CKE evolution, this needs a proper test to make sure the fix works after a CKE update
Comment #59
scott_euser commentedI couldn't see how we can add test coverage as per my comment in #35 - could use a pointer in the right direction. For convenience:
Comment #60
naveenvalechaHere's the patch for drupal core 10.4.6 which we're using on one of our website
Comment #62
philyFeels like no patching is needed with Drupal 11.3.2 (it may have fixed in earlier release but I've only checked using this one).
Comment #63
arthur.baghdasar commentedComment #64
dench0