Closed (fixed)
Project:
MaxLength
Version:
3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
4 Oct 2023 at 21:59 UTC
Updated:
12 Jun 2024 at 14:34 UTC
Jump to comment: Most recent
When using CKEditor 5 with MaxLength the character count stops when the text format is changed to another format that is using a CKEditor.
Add a MaxLength to a Text (formatted,long) field
After the page loads, on that text field change the Text format to another CKEditor 5 format.
Enter in text and you'll see the character content not update
After changing the text format, save the form. Return to edit the form and MaxLength will begin working again for the new format.
| Comment | File | Size | Author |
|---|---|---|---|
| maxlength-count-not-updating.png | 65.99 KB | acemichael |
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
ravi kant commentedThe issue is in Full HTML of ckeditor-5.
Comment #3
cedeweyThanks for reporting this issue acemichael,
I can reproduce this issue as well.
A workaround is to save the form, edit it again and the MaxLength functionality begins working again.
I'm going to update this to be a 3.x-dev issue since that is the new version we will be actively maintaining.
Comment #4
cedeweyComment #7
godotislateI put in an MR for a change that worked for me:
Testing steps:
1. Installed Drupal core with standard profile (10.3.x)
2. Installed MaxLength 3.0.0-beta1
3. Configured article content type's body field widget to have a maxlength
4. Created a new article node
5. Typed some text into body field (format initially Basic HTML) and confirmed counter matches typing
6. Switched formats to Full HTML and confirmed via dialog
7. Resumed typing and confirmed counter still matches characters typed.
The fix is slightly ugly with the use of the MutationObserver. I think it can be cleaned up once #3319358: Trigger event when Text Editor is attached in Drupal core is in, and there's event that can be listened for instead.
Going to put in needs review for feedback, though it probably needs tests.
Comment #8
joevagyok commentedThank you for the contribution! Would be nice to see a test for this without the solution to validate the issue and in a new commit adding the fix should make the test pass.
Comment #9
godotislateAdded test.
Failing test-only commit job: https://git.drupalcode.org/issue/maxlength-3391779/-/jobs/1182561
Fixed job: https://git.drupalcode.org/issue/maxlength-3391779/-/jobs/1182625
Comment #10
joevagyok commentedComment #11
chewie commentedFix looks good.
Comment #12
joevagyok commented