for Version 7.x-3.2

Follow-up to #2804757: Truncate option makes CKEditor cursor endlessly blink
https://www.drupal.org/node/2804757

When you begin typing in a CKEditor textarea and go over the character limit, the editor begins to blink and starts moving your cursor in and out. It only happens with the truncate html option enabled.

It seems once it pass the character limit, the process (in maxlength.js) enter and endless loop where the function ml.ckeditorChange() is called over and over, calling ml.calculate() again and again. Every time the cursor enters the textarea ml.ckeditorChange() is called, and when the limit is reached, for some reason related to the truncateHtml option, the cursor goes in and out of the textarea, endlessly.

Other issue :

https://www.drupal.org/node/2804757#comment-11755513 ->

The cursor is still being placed at the beginning of the editor every time the text is truncated.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rajiv.singh created an issue. See original summary.

rajiv.singh’s picture

Made improvements in patch https://www.drupal.org/node/2804757#comment-11755513 to fix :

The cursor is still being placed at the beginning of the editor every time the text is truncated

Which was not acceptable by client/QA.

juanolalla’s picture

Thanks!! I've updated the D8 patch with your improvements, in https://www.drupal.org/node/2804757#comment-11768893.

Two things I noticed, the cursor is placed always at the end, not in the same position the cursor was. This is a great improvement, it's just that is not the ideal, so it worths being mentioned.

The other is that I don't know what is this line in ml.ckeditorChange for:

$('#' + e.editor.element.getId()).val(ml['ckeditorGetData'](e));

The D8 patch works without it, so I wonder about that.

dawehner’s picture

idflood’s picture

So I tried the lastest dev version and the behavior with ckeditor was still glitchy. Once I applied the patch in #2 everything was much better : )

I rerolled the patch since it had absolute file path from drupal root instead of module root. I also copied the comments from the latest patch in https://www.drupal.org/node/2804757#comment-11768893 .

Also I tried to remove this line:

$('#' + e.editor.element.getId()).val(ml['ckeditorGetData'](e));

This made a "glitch" came back. In fact this line make sure we use the actual text data. Without it when I enter text in the textarea the counter display 125 which is probably the number of chars remaining when I loaded the page and the next frame the correct remaining chars. With this line added the number is always correct.

_KurT_’s picture

Confirm patch from #5 works for me

_KurT_’s picture

Status: Needs review » Reviewed & tested by the community
cedewey’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

We are only maintaining the Drupal 7 version of the module for critical security fixes, so I'm marking this Closed (works as designed). Thank you everyone for working on this issue. If you do want to maintain the Drupal 7 version, do reach out. We'd be happy to bring you on board as a maintainer.

I also encourage you, if you haven't already, to upgrade your site to Drupal 8/9. We are actively maintaining that version and you would enjoy all of the other features of the latest version of Drupal.