Problem/Motivation
Hello. We are using the comments feature provided by this module. We have a page with multiple entity forms loaded. The comments work only for the first form. The other ones don't have them loaded neither saved.
Steps to reproduce
- Prepare an entity type / bundle (e.g. a term) with a formatted field with a text format that allows comments.
- Create multiple instances from their respective edit form.
- Have a controller that includes multiple entity forms loaded by the standard entity form builder.
-
- => The comments for the first form work as expected.
- => The comments for the second form do not load. They do not save either even when comments are contributed.
Proposed resolution
The gist is to fix the commentsAdapter.js to support multiple form structure.
The problem lies mainly here (taken from the /build minified version because I have tested with this file):
const e = this.editor.plugins.get("CommentsRepository"),
t = this.editor.plugins.has("RealTimeCollaborativeComments"),
o = document.querySelector(this.storage.getSourceDataSelector("comments"));
By using document.querySelector
, the script gets the first instance of the comments-data
textarea.
As the forms share the same field ID, they share the same elementId. The querySelector is then not enough accurate.
I propose this change:
const e = this.editor.plugins.get("CommentsRepository"),
t = this.editor.plugins.has("RealTimeCollaborativeComments"),
o = this.editor.sourceElement.closest(".js-form-wrapper").querySelector(this.storage.getSourceDataSelector("comments"));
Other places in this module could be updated in a similar approach (revisionHistory, trackChanges, etc.) to support multiple forms in the same page.
Remaining tasks
User interface changes
API changes
Data model changes