Opened 4 months ago
Closed 3 months ago
#48543 closed defect (bug) (fixed)
Uncaught TypeError in comment-reply.js when 'id_form' is not 'commentform'
Reported by: | raamdev | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.3 | Priority: | normal |
Severity: | normal | Version: | 5.3 |
Component: | Comments | Keywords: | has-patch commit dev-reviewed |
Focuses: | javascript | Cc: |
Description
When comment_form()
is passed and id_form
argument other than the default of commentform
, clicking the Reply link on a comment produces the following error in the JavaScript console:
Uncaught TypeError: Cannot read property 'addEventListener' of null
This results in the page refreshing and defaulting to the non-JS behavior, breaking the intended functionality of moving the comment reply form underneath the comment being replied to.
It looks like this bug was introduced in r45790, where it's assumed that commentFormElement
contains a non-null reference to the comment form ID (config.commentFormId
), which is set to an ID of commentform
. If the ID is anything other than commentform
, the Uncaught TypeError is produced.
To reproduce the bug in trunk, you can modify comment_form()
in twentynineteen/inc/template-tags.php
to specify a custom comment form element id attribute (anything other than the default of commentform
produces the bug):
<?php comment_form( array( 'logged_in_as' => null, 'title_reply' => null, 'id_form' => 'commentform-' . get_the_ID() ) );
Attachments (1)
Change History (8)
#2
@
4 months ago
- Milestone changed from Awaiting Review to 5.3
Thanks for the ticket and the patch! Moving to 5.3, as this appears to be a regression.
#3
@
3 months ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 46700:
#4
@
3 months ago
- Keywords commit dev-feedback added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for a second committer's review before merging to the 5.3 branch.
Checks if commentFormElement is non-null before using it