We have this: The page doesn't reload between searches, so the back button doesn't work as expected on Media Search. If the user clicks the back button, they leave the search page and lose all their search history for the current session.
We want this: The back button should work to take the user to a previously conducted search. If the user clicks the back button after conducting a search, they should be taken to their previous search (or empty search, if it's their first search), and shouldn't lose their search history for the current session.
During development, please test the following:
- Test this feature while logged in AND logged out
- Test this feature on at least one mobile browser
QA Notes
This patch should be live on Wednesday of next week (August 19) assuming the train goes out normally.
During testing, check for the following behavior:
- If the user searches for a series of different terms ("Aardvark", "Bear", "Cat", "Dog"), then they should be able to use the browser's forward and back buttons to move back and forth in order ("Dog" back to "Cat" back to "Bear" etc).
- Each time the user moves forward or backwards in the history, the following things should happen:
- The URL params should update to reflect the query (specifically, the "q" params should change here)
- The search text in the input box should change to reflect the correct term (it should match the URL "q" param at all times)
- Moving forward or backwards in history to a different search term should clear existing results, show a pending state, and then load the first batch of results for the current term (should match the URL's "q" params at all times); additional pages loaded via scrolling will have to be re-loaded normally
- Moving back and forth between tabs should be recorded in the history the same way that adding new terms is; if the user searches for a given term ("Aardvark") and starts at the "Images" tab (the default), and moves across to Audio, Video, and Categories, then they should be able to use the forward/back buttons to return to the previous tabs in correct order. The URL "type" params should remain in sync at all times
- Moving between tabs using history navigation should trigger the loading of new results if available the same way that manually clicking between tabs does
- Clearing the results should be registered as a new history entry in the correct order, and the user should be able to navigate back to any "cleared" state just like they would for any other query
- The initial state of the page (including any query parameters present when the JS initializes) should be accessible through history navigation just like all subsequent states