Install
Works with Drupal: ^10.2 || ^11Using dev releases is not recommended, except for testing.
Using Composer to manage Drupal site dependencies
Alternative installation files
Release notes
First development release of the 2.0.x branch. Posting a comment no longer rebuilds the whole thread; only the comment that changed is updated on the page, which brings the module in line with how modern commenting systems work.
- A new comment is rendered on its own and added to the thread. A reply appears directly under its parent.
- Editing swaps the comment for the edit form and puts the saved comment back in the same place. Deleting removes the comment and its replies.
- The new comment is scrolled into view and highlighted.
- Ajax "Load more" and "Load Previous" pagination for paged comment fields. It is on by default and can be turned off with the "Use ajax pagination" checkbox in the comment field's formatter settings on Manage display.
- Works with several comment fields on one page, the same entity type shown more than once, comments in views, and entities in modals.
- Ajax comment fields use their own lazy builders, extending core's
CommentLazyBuilders. - Added extensive text coverage
Resolves:
#3113225: Don't rebuild the entire comment field/thread when posting a comment,
#3272398: Pagination after submitting a comment reply,
#3543214: Fix/add scroll to the just-added comment,
#3208008: Having the same type of entity on one page with comments enabled breaks the HTML ID uniqueness of the wrapper.
Upgrading from 8.x-1.x
Upgrading should be fairly simple, but there may be some breaking changes, so it's important that you review your comment fields and verify they're working as expected.
Run drush updb. It moves every comment field that had Ajax Comments turned on to the new formatter and keeps its ajax pagination choice. Fields that had it turned off stay on core's formatter.
Visit /admin/config/content/ajax_comments To configure the global settings and make sure everything is to your liking.
If you have custom theming or code built around the comment field markup or the module's Utility class, check it after upgrading: the field wrapper id is now built as {entity type}-{bundle}-{field name}-{entity id}, and Utility::getWrapperIdFromEntity() is replaced by Utility::getCommentFieldWrapperId(). To change the id, implement hook_ajax_comments_wrapper_id_alter().
Known issues
The comment form's Preview button does not work. Set "Preview comment" to Disabled on comment fields that use the Ajax Comments formatter.