Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#15353 closed defect (bug) (fixed)

Search box appears when there is nothing to search

Reported by: nacin Owned by: scribu
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.1
Component: Administration Keywords: has-patch 2nd-opinion
Focuses: Cc:
PR Number:


Title is pretty clear on this one. List table search boxes appear even when in the view, this is nothing to search.

This looks particularly ridiculous on the themes.php page when you have only one theme (and it is active).

Attachments (3)

15353.patch (635 bytes) - added by mfields 9 years ago.
has_items_or_search.15353.diff (3.8 KB) - added by scribu 9 years ago.
search_box.15353.diff (11.5 KB) - added by scribu 9 years ago.

Download all attachments as: .zip

Change History (15)

9 years ago

#1 @mfields
9 years ago

  • Cc michael@… added
  • Keywords has-patch 2nd-opinion added

Not sure if this is the best way to go, but I thought I would offer a solution.

#2 @PeteMall
9 years ago

A user can have 100 items listed per page but still want the search to narrow down the items.

#3 @scribu
9 years ago

I'm not entirely sure what "nothing to search" means. 0 items?

#4 @nacin
9 years ago

Correct, yes.

#5 @scribu
9 years ago

  • Owner set to scribu
  • Status changed from new to accepted

#6 @scribu
9 years ago

(In [16861]) Don't show search box if there are no themes available. See #15353

#7 @scribu
9 years ago

(In [16868]) Don't show search box if there are no items available. See #15353

#8 @scribu
9 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

#9 @scribu
9 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

In the wake of #15849, I don't think this was fixed properly.

We should hide the search only when there are no items at all and not when a search term yields no results.

#10 @scribu
9 years ago

search_box.15353.diff adds a search_box() method to WP_List_Table, which is then reused in all list screens, except themes.php, due to the fancy new filter. :)


In network/users.php, the submit_button() received 'post-query-submit', which was probably a bug. With the patch, it's 'submit'.

In edit.php and upload.php, the_search_query() was used. In the patch, _admin_search_query() is used. I think this is ok, since most filters probably only want to hook into the front-end anyway.

#11 @scribu
9 years ago

(In [17006]) Introduce WP_List_Table::search_box(). See #15353

#12 @scribu
9 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.