Problem/Motivation

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

Screenshot of drupal admin screen with CKEditor 5

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.

Comments

msbtterswrth created an issue. See original summary.

msbtterswrth’s picture

Issue summary: View changes
msbtterswrth’s picture

Issue summary: View changes
shailja179’s picture

Assigned: Unassigned » shailja179
Status: Active » Needs review

@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.

.ck-source-editing-area textarea{
    overflow: visible;
}

This should work.

msbtterswrth’s picture

@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.

smustgrave’s picture

Assigned: shailja179 » Unassigned
Status: Needs review » Active
Issue tags: +Needs tests

@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!

darvanen’s picture

StatusFileSize
new589.06 KB

Can 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.

darvanen’s picture

Status: Active » Needs work
StatusFileSize
new554 bytes

Here'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.

darvanen’s picture

StatusFileSize
new558 bytes

My 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.

wim leers’s picture

Title: [CKEditor 5] When editing source, scrolling is disabled » Regression: infinite height prevention disables scrolling in Source view
Issue tags: +CSS, +Usability
Related issues: +#3273755: CKEditor 5 should not grow to infinite height

https://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 😅

msbtterswrth’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new156.73 KB

I 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!

screenshot of drupal admin

msbtterswrth’s picture

Status: Reviewed & tested by the community » Needs work

Putting this back to NW because there isn't a test yet for it, my bad!

spokje’s picture

Status: Needs work » Needs review
StatusFileSize
new1.98 KB
new2.46 KB

First 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.

wim leers’s picture

Issue tags: -Needs tests +JavaScript

That 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. 😅🙈

+++ b/core/modules/ckeditor5/css/editor.css
@@ -19,3 +19,9 @@
+div.ck-source-editing-area textarea {

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:

.ck-editor__main > .ck-source-editing-area textarea {

Thoughts? 😊

darvanen’s picture

Issue tags: -JavaScript +JavaScript

The .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 an overflow: hidden from the injected styles for the editor.

wim leers’s picture

Assigned: Unassigned » lauriii

Hm … 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!

lauriii’s picture

Status: Needs review » Needs work

The selector proposed in #14 seems right based on the pre-existing selector 👍

darvanen’s picture

You'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!

spokje’s picture

StatusFileSize
new366 bytes
new2.48 KB

I’m nowhere near my computer right now so I can’t update it.

Never leave home without a computer...

Here's an updated patch, fail-patch stays the same.

spokje’s picture

Assigned: lauriii » Unassigned
Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Reviewed & tested by the community

  • lauriii committed 91609efd on 11.x
    Issue #3372922 by Spokje, darvanen, msbtterswrth, Wim Leers: Regression...

  • lauriii committed 70db0faf on 10.1.x
    Issue #3372922 by Spokje, darvanen, msbtterswrth, Wim Leers: Regression...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Committed 91609ef and pushed to 11.x. Also cherry-picked to 10.1.x. Thanks!

msbtterswrth’s picture

Thanks for the fast work everyone! 🎉

agarzola’s picture

Hi! 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!

spokje’s picture

Looking 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.

agarzola’s picture

Many thanks, Spokje! I was not sure whether the 10.0.x dates applied to 10.1.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

wim leers’s picture

This was released yesterday, in https://www.drupal.org/project/drupal/releases/10.1.2 🚀