Skip to content
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

Closed
2 tasks
obulat opened this issue Jan 3, 2023 · 1 comment · Fixed by #2101
Closed
2 tasks

Add the search term as a query parameter to the single result page #2082

obulat opened this issue Jan 3, 2023 · 1 comment · Fixed by #2101
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

Comments

@obulat
Copy link
Contributor

obulat commented Jan 3, 2023

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 and forward buttons, there is no way in the app to understand the navigation direction and set the search term accordingly.

Description

  • Set the search term as a query parameter of the single result page.
    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
  • Update the search store search term in 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.

@obulat obulat added 🟩 priority: low Low priority and doesn't need to be rushed ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository labels Jan 3, 2023
@anton202
Copy link
Contributor

anton202 commented Jan 12, 2023

hi, i have a couple of questions :)

  1. can i work on this issue?
  2. just out of curiosity. why the search results aren`t saved in, say, local storage, for the duration of the current session.
    wouldn't it be better to cache the results or am i missing something?

zackkrida pushed a commit that referenced this issue Feb 8, 2023
…ttons (#2101)

Co-authored-by: Olga Bulat <obulat@gmail.com>
Fixes #2082
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants