WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#30583 closed defect (bug) (fixed)

Switching Media Library Views Clears Search Query

Reported by: mrwweb Owned by: wonderboymusic
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.0.1
Component: Media Keywords: has-patch
Focuses: Cc:

Description

When switching from Grid to List view or List to Grid view in the media library while looking at search results, the search query is either lost or ignored. The results I'm seeing are quite inconsistent even in what goes wrong.

Theme & Variations on a Bug

Grid -> List

  1. Open Media Library in Grid View
  2. Do a search.
  3. Switch to list view.

Result: Search is lost. List view shows all items in media library. URL: /wp-admin/upload.php?mode=list

List -> Grid

  1. Open Media Library in List View
  2. Do a search.
  3. Switch to grid view.

Result: Search is lost. Grid view shows all items in media library. URL: /wp-admin/upload.php?mode=grid&attachment-filter&m=0&filter_action=Filter&s={SEARCH_TERM}&action=-1&paged=1&action2=-1&affected&_ajax_nonce=XXXXXXX

Where Things Get Weird: Adding Vars to URL

  1. Open Media Library in Grid View
  2. Manually append ?s={SEARCH_TERM} to URL. Hit RETURN.

Result A: Page reloads showing all items. Not search.

  1. Switch to Grid View.

Result B: Page loads in grid view with the search applied. What!? URL:/wp-admin/upload.php?s=koala&mode=list

I think I've seen some other weird variations of these things, but those are the three that I can consistently reproduce.

Attachments (1)

30583.diff (4.2 KB) - added by wonderboymusic 7 years ago.

Download all attachments as: .zip

Change History (4)

#1 @wonderboymusic
7 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.2

@wonderboymusic
7 years ago

#2 @wonderboymusic
7 years ago

30583.diff persists search across grid/list.

  • In Grid mode, when the page loads and s is in the URL, all attachments are loaded and then the search value is set, which will filter the attachments. If the page loads with the attachments already filtered, the library will have to be requery'd to get the full set, which will require weirder code.
  • When a user searches, the mode-switcher link for list view is updated dynamically to represent the current location.href in the proper mode= context.

#3 @wonderboymusic
7 years ago

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

In 31562:

Persist search terms across grid/list modes:

  • In grid mode, when the page loads and s is in the URL, all attachments are loaded and then the search value is set, which will filter the attachments. If the page loads with the attachments already filtered, the library will have to be requery'd to get the full set, which will require weirder code.
  • When a user searches, the mode-switcher link for list view is updated dynamically to represent the current location.href in the proper mode= and s= context.

Fixes #30583.

Note: See TracTickets for help on using tickets.