If a reply comment is submitted, and the user immediately attempts to reply to another comment, the comment body loads a default value of the previously submitted comment. Also, if a reply comment is submitted, and the user immediately attempts to add a new comment, the "add" form will rebuild after submit and load the previously submitted reply.

The reason for this problem is connected to how the Drupal Ajax framework functions. If an entire form is rebuilt after one has been closed, and drupal_html_id is being used to generate the form ID, it will have the same ID as the previous reply form. This causes the next instance of the form to pull the textarea value from cache rather than build cleanly.

There are only two ways to avoid this problem:

1) Selectively rebuild form fields when they need to be updated, rather than build the entire form.
2) Clear the textarea value after the new form is built.

The approach I've taken to fix this is #2.

Important Note: I've also included this same logic in patch #16 for Quote module support (https://www.drupal.org/project/ajax_comments/issues/1743292#comment-1289...). The reason for doing so is we don't want textarea reset if it is a quote. There needs to be extra conditional logic to handle this case.

If we can get this patch committed, I can re-create the Quote support patch with the extra logic that is needed. Or, if you want to commit the Quote support patch, it will take care of both of these items.

Please review, thanks.

Comments

ron_s created an issue. See original summary.

sgdev’s picture

StatusFileSize
new2.51 KB

Oops, sorry, I left a console.log in the javascript file from testing.

Here's an updated patch that removes the extra line, thanks.