-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When Body uses CKE5, additional Body entry fields are added to the form when clicking "Add another" for a different field #6347
Comments
This behavior exists also when any widget has any AJAX-enabled action. For example, when you have a File field in the node and select a file. The Body field gets duplicated every time. |
A bit of digging here: the The problem here is that AJAX requests will pass a Since the editor is not destroyed after ajax submission, it remains in the DOM, and a new one is created when the ajax response is processed. An obvious solution would be to get rid of that if statement, but I don't know enough about CKEditor to figure out if this may create other issues. Another possible solution is to check if the editor already exists in the dom before creating it (in Incidentally, only the first "Body" field is passed to the form handlers. |
Here's a PR: backdrop/backdrop#4618 I decided to go for the second option: avoid creating a CKE5 editor if it already exists on the page. I tried option 1 (always destroying the editor) but that creates some visual issues, since, when the editor is destroyed, the page temporarily shows the HTML markup for a second or two before the ajax response is processed. |
@argiepiano something similar has been reported recently #6344 But in this case I can reproduce it. |
Not necessarily. The "serialize" trigger, for instance, should allow the editor to write text to the hidden textarea form item. I'm not sure, why the attach runs for the unrelated body field outside the ajax container... 🤔 Seems to be normal behavior. However, I can confirm that preventing the additional attach, when there's already an attached editor works properly. |
Setting milestone to 1.27 - CKE5 will be part of it. BTW, weird, that I didn't see the same odd behavior with the other issue (related to paragraphs). |
Thanks @indigoxela. Yes, in my experience, I've seen all attach methods currently loaded in the browser run when ajax requests are processed. |
@argiepiano many thanks for the comment update. Much better. 👍 Re attaching multiple editors to the same form element: |
Thanks @argiepiano and @indigoxela! I merged backdrop/backdrop#4618 into 1.x for 1.27.0. |
Description of the bug
If your content type has a field (such as a Text (short) field) with unlimited cardinality, clicking "Add another" will add a new field to both, the Body field (!!) and the unlimited Text (short) field.
Steps To Reproduce
Actual behavior
Additional widgets are added to both, the "My text" field and the "Body" field.
Expected behavior
An additional widget should be added to "My text" field only.
Additional information
Add any other information that could help, such as:
The text was updated successfully, but these errors were encountered: