WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#17685 closed defect (bug) (fixed)

Posts Administration Pagination/Search Bug

Reported by: JohnONolan Owned by: azaozz
Milestone: 3.2 Priority: normal
Severity: minor Version: 3.1.4
Component: Administration Keywords: has-patch dev-feedback
Focuses: Cc:

Description

When searching through posts in the administration area, pagination is not reset when a new search term is entered.

Steps to reproduce:

  • Go to the main posts overview screen
  • Enter a search term and press enter
  • Navigate to page 3 of search results
  • Enter a new search term and press enter

Expected behaviour: You are taken to page 1 of search results for the new term

Actual behaviour: You are taken to page 3 of search results for the new term

Note: Search terms must both have sufficient results to reproduce this bug. If the first term has 3 pages of results and the 2nd term has 1 page of results then this bug doesn't appear.

Attachments (5)

17685.diff (1.7 KB) - added by greuben 4 years ago.
17685-paging.diff (1.6 KB) - added by solarissmoke 4 years ago.
17685-paging.2.diff (1.5 KB) - added by solarissmoke 4 years ago.
Simpler JS
17685-paging.3.diff (1.5 KB) - added by solarissmoke 4 years ago.
Works for all list tables
17685.2.diff (1.5 KB) - added by koopersmith 4 years ago.
Stylistic/comment tweaks.

Download all attachments as: .zip

Change History (20)

comment:1 @nacin4 years ago

  • Milestone changed from Awaiting Review to 3.2

Confirmed as a 3.0 to 3.1 regression. Moving to 3.2. If not a simple patch, it'll need a punt.

comment:2 @solarissmoke4 years ago

The problem is caused by the <input class="current-page" name="paged"> which is submitted along with the search query, and therefore forces the page number to be retained. This is an issue with the list-table class and so affects all list tables.

@greuben4 years ago

comment:3 follow-up: @greuben4 years ago

  • Keywords has-patch added; needs-patch removed

17685.diff - a bit hacky

comment:4 in reply to: ↑ 3 @sterlo4 years ago

Replying to greuben:

17685.diff - a bit hacky

Patch doesn't appear to resolve the issue.

I'm still seeing it.

  1. Add 10 posts
  2. Set post view to 5 per page
  3. Move to page 2
  4. Search for term
  5. Stays on page 2

comment:5 @solarissmoke4 years ago

This needs to be fixed for more than just search - it affects all filters. For example:

  • Filter posts by category and go to page 3 of the results
  • Now filter posts by another category - you will be taken to page 3 again (assuming both categories have enough posts)

I think this needs some overhaul of how wp-list-table handles filters and paging - and probably something that will have to wait till 3.3.

comment:6 @azaozz4 years ago

  • Milestone changed from 3.2 to Future Release

Agree with @solarissmoke, we would need to fix this for all filters and probably add some more logic to handle all possible combinations of filters and search results.

comment:7 @greuben4 years ago

  • Keywords needs-patch added; has-patch removed

comment:8 @nacin4 years ago

I have an idea for a patch.

This is a pretty bad regression and usability issue. Let's move this back to 3.2 for now.

comment:9 @nacin4 years ago

What if we printed the query string on the page, and on submit (via JS), we detect to see if the query string -- other than paged -- changed? At which point we then detach the paged inputs and let the submit continue.

comment:10 @solarissmoke4 years ago

  • Keywords has-patch dev-feedback added; needs-patch removed

@nacin I had a similar idea, based on using JS alone. See patch.

@solarissmoke4 years ago

comment:11 @nacin4 years ago

  • Milestone changed from Future Release to 3.2

I didn't consider that if the page wasn't changing, then it should be reset. That's a brilliant solution.

@solarissmoke4 years ago

Simpler JS

@solarissmoke4 years ago

Works for all list tables

comment:12 @solarissmoke4 years ago

First pass only worked for wp-admin/edit.php, have updated it to work with any form that uses the list-table class.

Last edited 4 years ago by solarissmoke (previous) (diff)

@koopersmith4 years ago

Stylistic/comment tweaks.

comment:13 @koopersmith4 years ago

Other than a slight tweak or two, looks great to me. Nice solution! :)

comment:14 @azaozz4 years ago

Would have preferred backend/PHP solution. Perhaps force paged=1 when submitting new filter or new search?

Also we are adding another script file, queueing it, checking dependencies, etc. just for 4-5 lines of JS? Perhaps better to add it to common.js as it's used on several admin pages.

Version 0, edited 4 years ago by azaozz (next)

comment:15 @azaozz4 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In [18237]:

Fix pagination when searching or filtering, props solarissmoke, koopersmith, fixes #17685

Note: See TracTickets for help on using tickets.