Drupal.editors.ckeditor5.onChange event has outdated data when user types too fast.

Created on 25 April 2024, 7 months ago

Problem/Motivation

The release of Drupal 10.2.5 has introduced a regression in (but not limited to) Site Studio's implantation of CKEditor5 that results in user input being lost if they type too fast.

  1. A user types into the Site Studio wysiwyg field
  2. Site Studio uses the Drupal.editors.ckeditor5.onChange event to pull the value of the editor using ckInstance.getData() and store that in a JSON blob.
  3. Since this change https://git.drupalcode.org/project/drupal/-/commit/5540b5f84a6ae7899df01... if a user types multiple characters in quick succession, only the first character they type is registered in the on change event and all subsequent inputs are lost.
  4. I think the issue is due to the use of the immediate variable on the debounce call.

Steps to reproduce

If you paste this snippet into the JS console on a node page with a CKEditor instance and then type into the editor quickly vs slowly, you can see the issue. When typing quickly the onChange event is fired after the first user input but not fired again after the user types their last input.

Drupal.editors.ckeditor5.onChange(document.getElementById('edit-body-0-value'), () => {
 const ckInstance = Drupal.CKEditor5Instances.values().next().value;
  console.log(ckInstance.getData())
});

I've attached a video showing the above steps to test demonstrating the issue.

🐛 Bug report
Status

Active

Version

10.2

Component
CKEditor 5 

Last updated 1 day ago

Created by

🇬🇧United Kingdom jessebaker

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024