Maxlength hard limit doesn't work for CKEditor 5 widget

Created on 30 December 2024, 9 days ago

Problem/Motivation

When maxlength is configured with a "Hard" limit option for a field with CKEditor 5 widget, the editor text doesn't seem to get trimmed when the page is loaded.

The counter seems to work fine, but nothing happens to the editor text.

Steps to reproduce

1. Enable the core ckeditor5 module.
2. Enable the maxlength module.
3. Go to any content entity type and add a field of type "Text (formatted, long)".
4. Set the "Text area (multiple rows)" widget for the field created in step #3.
5. Configure widget maxlength settings -
Maximum length: 20 characters
Keep others settings as they are.
6. Create node content, and for the text area field, add content of more than 20 characters. Save node.
7. Go to the widget settings section again and enable the "Hard" limit option.
8. Go to the edit node page of the content created in step #6.
You will find that the text is not trimmed to 20 characters. The counter will show "0" characters left.

Proposed resolution

The ckeditor function defined in maxlength.js file only triggers when a change to editor text is made. Update the logic to also work for page load/form or field rebuilt via ajax callback.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇮🇳India gaurav_manerkar Vasco Da Gama, Goa

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

Comments & Activities

Production build 0.71.5 2024