Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8dcc7aa
Administration: Fix Tags screen 'No tags found' message and tablenav …
SainathPoojary Apr 30, 2025
338d2c7
Administration: Update tag count display in tablenav after adding/rem…
SainathPoojary May 5, 2025
0577a55
Administration: Show search box and tablenav when items are present i…
SainathPoojary May 5, 2025
9f820be
Administration: Adjust tag count handling for pagination consistency
SainathPoojary May 6, 2025
35f7f4a
Administration: Fix Tags screen 'No tags found' message and tablenav …
SainathPoojary Apr 30, 2025
e9529b3
Administration: Update tag count display in tablenav after adding/rem…
SainathPoojary May 5, 2025
8f12367
Administration: Show search box and tablenav when items are present i…
SainathPoojary May 5, 2025
ae6352a
Administration: Adjust tag count handling for pagination consistency
SainathPoojary May 6, 2025
418746c
Merge branch 'fix/tags-js-ui' of https://github.com/SainathPoojary/wo…
joedolson Oct 31, 2025
4dcc14c
Merge branch 'trunk' into pr/8761
joedolson Oct 31, 2025
eeb7d1a
Restore focus management
joedolson Oct 31, 2025
d3145cd
Use `wp.i18n._n` to handle singular/plural translations.
joedolson Oct 31, 2025
3cc5625
Don't duplicate table nav update code
joedolson Oct 31, 2025
1df72e4
Merge branch 'trunk' into fix/tags-js-ui
joedolson Feb 24, 2026
b8818c3
Administration: Fix empty-state colspan and i18n count parsing in tag…
SainathPoojary Jul 13, 2026
89a3582
Merge branch 'trunk' into fix/tags-js-ui
SainathPoojary Jul 13, 2026
5d1340d
Update src/js/_enqueues/admin/tags.js
joedolson Jul 21, 2026
d4d523f
Merge branch 'trunk' into fix/tags-js-ui
joedolson Jul 21, 2026
e11a0f7
Potential fix for pull request finding
joedolson Jul 21, 2026
5b2fea0
Merge remote-tracking branch 'upstream/trunk' into pr/8761
joedolson Jul 23, 2026
c237975
Allow count & bulk actions to show on first add.
joedolson Jul 23, 2026
74a9b4d
Translatable & comment
joedolson Jul 23, 2026
4c66e84
Merge branch 'trunk' into fix/tags-js-ui
joedolson Jul 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 54 additions & 3 deletions src/js/_enqueues/admin/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ jQuery( function($) {
nextFocus = prevFocus;
}
}

tr.fadeOut('normal', function(){ tr.remove(); });
tr.fadeOut('normal', function() {
tr.remove();
updateTableNavCount();
});

/**
* Removes the term from the parent box and the tag cloud.
Expand All @@ -73,7 +75,7 @@ jQuery( function($) {
$('a.tag-link-' + data.match(/tag_ID=(\d+)/)[1]).remove();
nextFocus.trigger( 'focus' );
message = wp.i18n.__( 'The selected tag has been deleted.' );

} else if ( '-1' == r ) {
message = wp.i18n.__( 'Sorry, you are not allowed to do that.' );
$('#ajax-response').empty().append('<div class="notice notice-error"><p>' + message + '</p></div>');
Expand Down Expand Up @@ -103,6 +105,53 @@ jQuery( function($) {
tr.find( ':input, a' ).prop( 'disabled', false ).removeAttr( 'tabindex' );
}

/**
* Updates the item count and table navigation after a tag is added or removed.
*
* Tags are added and removed client-side, but the item count, the `.tablenav`
* regions, the search box, and the empty-state row are otherwise only
* reconciled by PHP on a full page reload. This keeps them in sync.
*
* @param {string} [action] Pass 'add' when a tag was added. Any other value,
* including none, is treated as a removal.
*
* @return {void}
*/
function updateTableNavCount( action ) {
var $displayingNum = $( '.tablenav-pages .displaying-num' ),
currentCount = parseInt( $displayingNum.first().text().replace( /[^0-9]/g, '' ), 10 ) || 0,
itemCount = ( 'add' === action ) ? currentCount + 1 : Math.max( currentCount - 1, 0 ),
formattedCount = itemCount.toLocaleString();

$displayingNum.text(
wp.i18n.sprintf(
/* translators: %s: Number of items. */
wp.i18n._n( '%s item', '%s items', itemCount ),
formattedCount
)
);

if ( itemCount < 1 ) {
// No tags remain: show the empty-state row and hide the navigation.
var $list = $( '#the-list' );

if ( ! $list.find( 'tr.no-items' ).length ) {
var colspan = $list.closest( 'table' ).find( 'thead > tr' ).first().children( ':not(.hidden)' ).length;
$list.append(
'<tr class="no-items"><td class="colspanchange" colspan="' + colspan + '">' +
wp.i18n.__( 'No tags found.' ) +
'</td></tr>'
);
}
$( '.tablenav > *' ).hide();
$( 'p.search-box' ).hide();
} else {
$( '#the-list' ).find( 'tr.no-items' ).remove();
$( '.tablenav > *' ).show();
$( 'p.search-box' ).show();
}
}
Comment thread
joedolson marked this conversation as resolved.

/**
* Adds a deletion confirmation when removing a tag.
*
Expand Down Expand Up @@ -192,6 +241,8 @@ jQuery( function($) {
}

$('input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):visible, textarea:visible', form).val('');

updateTableNavCount( 'add' );
});

return false;
Expand Down
14 changes: 10 additions & 4 deletions src/wp-admin/includes/class-wp-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,8 @@ protected function get_items_per_page( $option, $default_value = 20 ) {
*/
protected function pagination( $which ) {
if ( empty( $this->_pagination_args['total_items'] ) ) {
// translators: Number is a fixed value. This is default text when no items are found.
echo '<div class="tablenav-pages no-pages"><span class="displaying-num">' . __( '0 items' ) . '</span></div>';
return;
}

Expand Down Expand Up @@ -1685,12 +1687,16 @@ protected function display_tablenav( $which ) {
?>
<div class="tablenav <?php echo esc_attr( $which ); ?>">

<?php if ( $this->has_items() ) : ?>
<div class="alignleft actions bulkactions">
<?php
$visibility = ' hidden';
if ( $this->has_items() ) {
$visibility = '';
}
?>
<div class="alignleft actions bulkactions<?php echo $visibility; ?>">
<?php $this->bulk_actions( $which ); ?>
</div>
<?php
endif;
<?php
$this->extra_tablenav( $which );
$this->pagination( $which );
?>
Expand Down
Loading