Problem/Motivation
When the hard limit is exceeded, the cursror winds up at the beginning of the text area momentarily then jumps back to the end.
Steps to reproduce
Core 11.2.8
MaxLength 3.1.3 (currently latest 3.x dev)
- Clean install using standard profile
- Add a formatted, long text field to article content type. This will use CKEditor.
- Add or edit an article node
- Exceed the character limit, smash keys. Notice the cursor appears briefly at the beginning of the text. Sometimes characters can slip in before the cursor is placed at the end of the text, which causes characters at the end to be lost.
Note, I can reproduce this on a reasonably modern and powerful Mac w/FireFox. This is also happening on a junk Windows machine w/Edge where the effect is much easier to observe.
Proposed resolution
Make the content changes via CKEditor's model to avoid weird cursor behavior with editor.setData.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | maxlength-cursor_jumps_to_beginning_of_text-3573209-2.patch | 1.96 KB | kerasai |
Issue fork maxlength-3573209
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
kerasai commentedPatch attached to fix CKEditor5 cursor behavior.
This avoids using the
editor.setDatamethod which places the cursor at the beginning of the text, and instead manipulated the content via theeditor.modelproperty.I am reasonably proficient w/JS, but this was created using Claude Code and there are likely a some things that could be cleaned up. A review by someone with CKEditor expertise may be due as well.
I did test the heck out if it, though, and it seems to work great in my case.
Comment #3
arthur.baghdasar commentedWorking great for me. Would love to see this in the next release.
Comment #6
joevagyok commentedThank you for the work on this @kerasai! Tested and works fine.
Comment #7
joevagyok commented