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)

  1. Clean install using standard profile
  2. Add a formatted, long text field to article content type. This will use CKEditor.
  3. Add or edit an article node
  4. 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.

Issue fork maxlength-3573209

Command icon 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

kerasai created an issue. See original summary.

kerasai’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.96 KB

Patch attached to fix CKEditor5 cursor behavior.

This avoids using the editor.setData method which places the cursor at the beginning of the text, and instead manipulated the content via the editor.model property.

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.

arthur.baghdasar’s picture

Status: Needs review » Reviewed & tested by the community

Working great for me. Would love to see this in the next release.

joevagyok made their first commit to this issue’s fork.

joevagyok’s picture

Thank you for the work on this @kerasai! Tested and works fine.

joevagyok’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • joevagyok committed 9d9cfad0 on 3.x
    Issue #3573209: Fix cursor jumps to beginning of text.
    

Status: Fixed » Closed (fixed)

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