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
- Drupal 10.2, Ajax comments 8.x-1.x-dev
- Go to Manage > Content > Comments
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | ajax_comments-3419586-2.patch | 1.13 KB | iamdroid |
Issue fork ajax_comments-3419586
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
Comment #2
iamdroid commentedHere is the patch.
Comment #3
damienmckennaComment #4
erutan commentedAfter 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.
Comment #8
idebr commentedAdded
\Drupal\Tests\ajax_comments\FunctionalJavascript\AjaxCommentsFunctionalTest::testAdminInterfaceto 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!