Problem/Motivation
When editing the source in a CKE5 field, you are unable to scroll.

Steps to reproduce
Step 1. Create a long text, formatted field within an entity (mine are on nodes).
Step 2. Create a new entity and enter some text into the CKE input box.
Step 3. Click the 'Source' button and make sure there is enough text to overflow the viewport.
Step 4. Using your mousewheel while you are focused on the CKE element, scroll down and see that there are no scrollbars within the element and that the entire page scrolls. You ARE able to arrow down through the lines via keyboard.
Proposed resolution
It appears that removing the `overflow:hidden` on the `.ck-source-editing-area textarea` element and also removing `white-space: pre-wrap` on `.ck-source-editing-area textarea, .ck-source-editing-area::after` seems to fix the issue.
It does not appear that this is upstream, based on the cke demo site I'm unable to reproduce the issue there, but i have been able to reproduce this on both a fresh d10 install and a d9 site that was recently upgraded to d10.
Note: This ONLY affects source view, and NOT the normal content entry view.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 3372922-19.patch | 2.48 KB | spokje |
| #19 | interdiff_13-19.txt | 366 bytes | spokje |
| #13 | 3372922-13-test-only-should-fail.patch | 1.98 KB | spokje |
| #11 | cke5-scrollbars.png | 156.73 KB | msbtterswrth |
Comments
Comment #2
msbtterswrth commentedComment #3
msbtterswrth commentedComment #4
shailja179 commented@msbtterswrth,
This was a requirement to disable this scroll in https://ckeditor.com/old/forums/CKEditor-3.x/Disable-Scroll-Bar.
If you want to enable this, you can use this code in your custom css with some parent id.
This should work.
Comment #5
msbtterswrth commented@shailja179, that forum post is for cke 3 from over 10 years ago.
This is a new issue that did not occur in cke4 in d8,d9 or d10. It is new to cke 5. Are you saying this is expected behavior? I can not see the full content of my source code within the editor currently without adding custom code.
I can certainly patch it locally, but this is already happening on three client sites, it seems like we should either fix this upstream by either fixing the height so we can see the entire contents or add a scroll back in like in cke4.
Comment #6
smustgrave commented@shailja179 FYI should avoid assigning tickets to yourself unless you're a maintainer
https://www.drupal.org/docs/develop/issues/issue-procedures-and-etiquett...
Should just leave a comment you'll be working on it
Seems like a valid bug so moving to Active as there is no patch yet.
Thanks!
Comment #7
darvanenCan confirm this is a valid bug and it is upstream, on their snippets site they alter the CSS to cater for it:
I propose we do the same thing in the core ckeditor5 module.
Comment #8
darvanenHere's a patch that solves the problem for Drupal 10. Suggestions on how to test this welcome, can't guarantee I'll have the time to create one.
Leaving NW for a test.
Comment #9
darvanenMy IDE moved the 80 character line 🙄
I should also point out that I added the "div" to the front of the selector to give it priority of the styles that load with the editor.
Comment #10
wim leershttps://github.com/ckeditor/ckeditor5/issues/10731 says this was fixed in October 2021?!
I investigated and found … that this is a regression introduced by #3273755: CKEditor 5 should not grow to infinite height 😅
Comment #11
msbtterswrth commentedI tested the patch in #9 from @darvanen and that is working excellently for me! Not sure if there's anything else that needs to be done, but I marked it as RTBC. Thanks for the quick work friends!
Comment #12
msbtterswrth commentedPutting this back to NW because there isn't a test yet for it, my bad!
Comment #13
spokjeFirst attempt at a Nightwatch test, also it seems that testing if an element has scrollbars is not without it's own challenges.
(My implementation was based on https://stackoverflow.com/questions/4814398/how-can-i-check-if-a-scrollb...)
Defenitely needs some JavaScript-Jefe eyes on this.
Comment #14
wim leersThat test does appear to reproduce the problem and accurately verify failure without the patch and success with! 👍 🚀
But … I still think this is a slightly incorrect solution. 😅🙈
Compare this selector to the selector above:
.ck-editor__main > :is(.ck-editor__editable, .ck-source-editing-area) {, which as I wrote in #10 is what introduced this bug (in #3273755: CKEditor 5 should not grow to infinite height).AFAICT the selector should be more specific, I suspect this:
Thoughts? 😊
Comment #15
darvanenThe
.ck-editor__main > :is(.ck-editor__editable, .ck-source-editing-area)selector isn't directly affecting the text area. The text area is just inheriting anoverflow: hiddenfrom the injected styles for the editor.Comment #16
wim leersHm … summoning @lauriii 🤓
EDIT: I see you're the maintainer of https://www.drupal.org/project/advanced_email_validation — I discovered that last week, looks really cool! 🤩 Thanks for building that!
Comment #17
lauriiiThe selector proposed in #14 seems right based on the pre-existing selector 👍
Comment #18
darvanenYou're very welcome 😁
I needed the library and it seemed daft not to contribute it.
The selectors from 14 will work too, there must be some kind of Drupal practice here I’m not aware of. I’m nowhere near my computer right now so I can’t update it.
Nicely done with that test too!
Comment #19
spokjeNever leave home without a computer...
Here's an updated patch, fail-patch stays the same.
Comment #20
spokjeComment #21
wim leersComment #24
lauriiiCommitted 91609ef and pushed to 11.x. Also cherry-picked to 10.1.x. Thanks!
Comment #25
msbtterswrth commentedThanks for the fast work everyone! 🎉
Comment #26
agarzola commentedHi! We just ran into this issue and our client is asking about a fix. Before we go and apply this patch ourselves, is there a way to find out when a 10.1.2 release might be published containing this fix?
Thanks!
Comment #27
spokjeLooking at https://www.drupal.org/about/core/policies/core-release-cycles/schedule#... (and replacing 10.0.x with 10.1.x, since the versions written there seem a tad outdated) 10.1.2 should be in a theatre/release near you around Aug. 2nd, so in 2 weeks.
Comment #28
agarzola commentedMany thanks, Spokje! I was not sure whether the 10.0.x dates applied to 10.1.x.
Comment #30
wim leersThis was released yesterday, in https://www.drupal.org/project/drupal/releases/10.1.2 🚀