From 64944b7a8717608996415b4cabcccaaaf91a95ee Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 20 Aug 2015 05:53:41 +0000 Subject: [PATCH] Comments List Table: * In a view that initially has comments, but they get removed due to user actions: show the `No Items` row instead of bombing out and showing nothing (which looks broken) * To accomplish this, in `WP_Comments_List_Table::display()`: call `->display_rows_or_placeholder()` instead of `->display()` * Listen for the end of row `.fadeOut()`s if necessary using jQuery Promises Fixes #11200. git-svn-id: https://develop.svn.wordpress.org/trunk@33657 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-comments-list-table.php | 5 ++++- src/wp-admin/js/edit-comments.js | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 52d3f50ba6..8bbfb3e836 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -409,7 +409,10 @@ class WP_Comments_List_Table extends WP_List_Table { - items = $this->extra_items; $this->display_rows(); ?> + items = $this->extra_items; + $this->display_rows_or_placeholder(); + ?> diff --git a/src/wp-admin/js/edit-comments.js b/src/wp-admin/js/edit-comments.js index 89a32a88b7..11c00cbf7c 100644 --- a/src/wp-admin/js/edit-comments.js +++ b/src/wp-admin/js/edit-comments.js @@ -152,7 +152,7 @@ setCommentsList = function() { // In admin-ajax.php, we send back the unix time stamp instead of 1 on success delAfter = function( r, settings ) { - var total_items_i18n, total, + var total_items_i18n, total, animated, animatedCallback, response = true === settings.parsed ? {} : settings.parsed.responses[0], commentStatus = true === settings.parsed ? '' : response.supplemental.status, @@ -333,9 +333,22 @@ setCommentsList = function() { return; } - theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() ); + theList.get(0).wpList.add( theExtraList.children( ':eq(0):not(.no-items)' ).remove().clone() ); refillTheExtraList(); + + animated = $( ':animated' ); + animatedCallback = function () { + if ( ! $( '#the-comment-list tr:visible' ).length ) { + theList.get(0).wpList.add( theExtraList.find( '.no-items' ).clone() ); + } + }; + + if ( animated.length ) { + animated.promise().done( animatedCallback ); + } else { + animatedCallback(); + } }; refillTheExtraList = function(ev) {