[wp-trac] [WordPress Trac] #65298: Searched text is not cleared from the Library search bar after refresh

WordPress Trac noreply at wordpress.org
Thu Jun 4 00:24:36 UTC 2026


#65298: Searched text is not cleared from the Library search bar after refresh
---------------------------------------+-----------------------------
 Reporter:  abduremon                  |       Owner:  westonruter
     Type:  defect (bug)               |      Status:  reviewing
 Priority:  normal                     |   Milestone:  7.1
Component:  Administration             |     Version:  4.9
 Severity:  major                      |  Resolution:
 Keywords:  has-screenshots has-patch  |     Focuses:  administration
---------------------------------------+-----------------------------
Changes (by huzaifaalmesbah):

 * keywords:  has-screenshots has-patch needs-testing => has-screenshots
     has-patch


Comment:

 == Test Report

 Patch tested: https://github.com/WordPress/wordpress-develop/pull/11938

 === Environment

 • WordPress: 7.1-alpha-20260522.071116
 • Subdirectory: No
 • PHP: 7.4.33
 • Server: PHP.wasm
 • Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
 • Browser: Chrome 148.0.0.0
 • OS: macOS
 • Theme: Twenty Twenty-Five 1.5
 • MU Plugins: None activated
 • Plugins:
   • Test Reports 1.3.0

 === Steps taken

 1. Opened the Media Library in Grid View via Media → Library in the admin
 sidebar.
 2. Typed a search term (e.g., "test") into the search bar in the top-right
 corner and pressed Enter.
 3. Observed the browser URL updated to include ?search=test (e.g.,
 upload.php?search=test).
 4. Manually cleared the search input field by selecting all text and
 deleting it.
 5. Pressed Enter / waited for the search to trigger — confirmed the
 browser URL reset back to upload.php without the ?search= parameter.
 6. Refreshed the page — confirmed the search input remained empty and no
 stale search text reappeared.
 7. ✅ Patch is solving the problem — the ?search= query parameter is now
 correctly removed from the URL when the search input is cleared, and
 refreshing the page no longer restores the old search term.

 === Expected result

 • When a user clears the search text in the Media Library search bar, the
 ?search= query parameter should be removed from the browser URL. On page
 refresh, the search input should remain empty and not re-populate with the
 previously searched term.

 === Additional Notes

 • Before the patch, clearing the search input did not update the URL — it
 stayed at upload.php?search=old-term. A page refresh would then read the
 stale URL parameter and re-fill the search field.
 • The root cause was in src/js/media/views/frame/manage.js — the
 gridRouter.navigate() was only called when the search value was truthy, so
 clearing the input (empty string = falsy) never triggered a URL reset.
 • The fix ensures gridRouter.navigate() is called unconditionally,
 resetting the URL to upload.php when the search box is emptied.

 === Support Content

 Playground URL with PR applied:
 https://playground.wordpress.net/?core-pr=11938

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/65298#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list