Skip to content

Commit

Permalink
Administration: Fix pagination in categories, tags, and plugins tables.
Browse files Browse the repository at this point in the history
Fix an issue introduced in [59134] that prevented manual entry of a page number in the pagination input field from navigating pages. Requiring validation of the bulk actions input also impacted other inputs nested in the same form.

Also fixes a pre-existing bug where it was not possible to navigate to page 1 using the input field.

Props ffffelix, im3dabasia1, apermo, rishavdutta, joedolson, swissspidy, jorbin, joedolson.
Fixes #62534.

git-svn-id: https://develop.svn.wordpress.org/trunk@59727 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
joedolson committed Jan 29, 2025
1 parent 8246f31 commit 382211a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/js/_enqueues/admin/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1310,10 +1310,19 @@ $( function() {
$document.trigger( 'wp-notice-added' );
};

// Stores initial pagination value for comparison.
var initialPagedValue = document.querySelector( '#current-page-selector' ).value;

$( '.bulkactions' ).parents( 'form' ).on( 'submit', function( event ) {
var form = this,
submitterName = event.originalEvent && event.originalEvent.submitter ? event.originalEvent.submitter.name : false;

var currentPagedValue = form.querySelector( '#current-page-selector' ).value;

if ( initialPagedValue !== currentPagedValue ) {
return; // Pagination form submission.
}

// Observe submissions from posts lists for 'bulk_action' or users lists for 'new_role'.
var bulkFieldRelations = {
'bulk_action' : 'action',
Expand Down
3 changes: 3 additions & 0 deletions src/wp-admin/edit-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@
if ( $pagenum > 1 ) {
$location = add_query_arg( 'paged', $pagenum, $location ); // $pagenum takes care of $total_pages.
}
if ( 1 === $pagenum ) {
$location = remove_query_arg( 'paged', $location );
}

/**
* Filters the taxonomy redirect destination URL.
Expand Down

0 comments on commit 382211a

Please sign in to comment.