Problem/Motivation

In Drupal 10.1 a modal form for delete action in admin UI has been introduced (see #2253257: Use a modal for entity delete operation links). Basically, now the delete action in admin UI is handled by Ajax request.
The Ajax comments module alters the delete comment form for Ajax requests for handling action links on the Ajax comment form. It relies on attributes added by the JS code of the Ajax comments module but for admin UI it is not the case, and some logic gets broken.

Because of this, the comment delete action is stuck on an unexpected Ajax response and the page is not reloading as it should after a successful action.

Example of log messages:

Deprecated function: substr(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\ajax_comments\TempStore->getSelectorValue() (line 67 of /web/modules/contrib/ajax_comments/src/TempStore.php)

Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\ajax_comments\TempStore->getSelectorValue() (line 67 of /web/modules/contrib/ajax_comments/src/TempStore.php)

Steps to reproduce

  1. Drupal 10.2, Ajax comments 8.x-1.x-dev
  2. Go to Manage > Content > Comments
  3. Choose some comment, expand operations link dropdown > Delete > Delete

Expected behaviour
The comment is deleted and has gone from the list.

Actual behavior
Nothing seems changed. However, the comment is actually deleted but the page is not refreshed.

Proposed resolution

Add a few guard clauses to prevent the execution of unintended code parts.

Remaining tasks

No.

User interface changes

No.

API changes

No.

Data model changes

No.

CommentFileSizeAuthor
#2 ajax_comments-3419586-2.patch1.13 KBiamdroid
Command icon Show commands

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

iamdroid created an issue. See original summary.

iamdroid’s picture

StatusFileSize
new1.13 KB

Here is the patch.

damienmckenna’s picture

Status: Active » Needs review
erutan’s picture

After applying this patch if I create a comment from a field in a view it takes me to the admin edit page for that entity. Drupal 10.3.1.

idebr made their first commit to this issue’s fork.

  • idebr committed 2ee51299 on 8.x-1.x
    Issue #3419586: Customizations for comment delete form interfere with...
idebr’s picture

Status: Needs review » Fixed

Added \Drupal\Tests\ajax_comments\FunctionalJavascript\AjaxCommentsFunctionalTest::testAdminInterface to confirm the bug.

The patch in #2 fixes the issue. Committed!

Re #4: can you file a new issue for your use case and describe the expected vs. the current behavior? Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.