Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#46963 new defect (bug)

Comments meta box offset bug for custom comment types

Reported by: mikejolley's profile mikejolley Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Comments Keywords: has-patch needs-testing
Focuses: ui, administration Cc:

Description

There is a conflict in the 'comments' meta box when used in combination with custom comment types.

The Show more comments link loads duplicates, without an offset due to this line of code:

https://github.com/WordPress/WordPress/blob/72979b167d913bf49745fa737654bdf6d13168de/wp-admin/js/post.js#L99

this.st = jQuery('#the-comment-list tr.comment:visible').length;

For custom comment types, the comment class may not exist. See how comment classes are generated here:

https://github.com/WordPress/WordPress/blob/03240dd3f4442546562824bc6a10ed7c197bd6b2/wp-includes/comment-template.php#L466

<?php
$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;

You can see an example of this with WooCommerce which uses a comment type named 'review' (https://github.com/woocommerce/woocommerce/issues/23313). Because the comments out output without the comment class and instead they have a review class, the JS code fails to set the correct offset.

Possible solutions:

  • Output comment class for custom comment types in addition to their custom class.
  • Revise jquery selector to be more generic e.g. count the tr elements instead.

Attachments (2)

46963.patch (1.9 KB) - added by hardipparmar 5 years ago.
I have fixed the "Comments meta box offset bug for custom comment types" issue.
46963.2.patch (1.9 KB) - added by hardipparmar 5 years ago.
In the above patch, file patch is not included so I have created another patch. Please consider this new patch for this issue.

Download all attachments as: .zip

Change History (5)

#1 @SergeyBiryukov
5 years ago

  • Component changed from Administration to Comments
  • Focuses ui administration added

@hardipparmar
5 years ago

I have fixed the "Comments meta box offset bug for custom comment types" issue.

@hardipparmar
5 years ago

In the above patch, file patch is not included so I have created another patch. Please consider this new patch for this issue.

#2 @hardipparmar
5 years ago

46963.patch file in the file path is not included so I have created another patch. (46963.patch [46963.2.patch]) Please consider this new patch for this issue.

#3 @andraganescu
5 years ago

  • Keywords has-patch needs-testing added
Note: See TracTickets for help on using tickets.