Media: Reset search query parameter in URL when search input is cleared#11938
Media: Reset search query parameter in URL when search input is cleared#11938NoumaanAhamed wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Summary
Fixes an issue where the searched text is not cleared from the Library search bar URL and input field after the text is removed and the page is refreshed.
Root Cause
In
src/js/media/views/frame/manage.js, theinputevent throttle handler only invokedthis.gridRouter.navigate()whenvalwas truthy (non-empty):When a user completely deleted the search query,
valbecame an empty string (falsy). The router never received the navigate command, meaning the browser's address bar was left stuck on?search=some-term. Refreshing the page then re-parsed the search parameter from the URL and filled the input field back up.Solution
this.gridRouter.navigate()unconditionally. When the search box is cleared, it correctly navigates back to the base URL (upload.php), removing the search query parameter from the URL.Changes
src/js/media/views/frame/manage.jsinputcallback to always invokegridRouter.navigate()so clearing the input resets the URL query string back to the baseupload.phppage.Testing
?search=valupload.php?search=testtoupload.phpTrac ticket: https://core.trac.wordpress.org/ticket/65298
Use of AI Tools
AI assistance: No