This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
Add the search term as a query parameter to the single result page #2082
Labels
💻 aspect: code
Concerns the software code in the repository
✨ goal: improvement
Improvement to an existing user-facing feature
🟩 priority: low
Low priority and doesn't need to be rushed
Problem
Currently, the single result page re-uses the search term value saved in the store to set the value of the search bar in the header. This works when browsing without the browser navigation. However, if you hit the browser
back
andforward
buttons, there is no way in the app to understand the navigation direction and set the search term accordingly.Description
So, when navigating from the search result for "cat" to the first result, your route would be
/image/f9384235-b72e-4f1e-9b05-e1b116262a29?q=cat
beforeRouteEnter
Only update if navigating from the "search" page, and the "q" query parameter is available.
Alternatives
We could also wait until we update to Nuxt 3, which makes it possible to understand whether the user pressed the "forward" or "back" button. However, we would still have to save the search term history somewhere to update it correctly.
Additional context
For more discussion of this issue, look at the comments in #2046.
The text was updated successfully, but these errors were encountered: