fix: Recipe Search Quirks and Session Storage #3541
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
(REQUIRED)
What this PR does / why we need it:
(REQUIRED)
This fixes a few issues with the recipe search state from #3332. #3332 fixed most issues, but introduced a few smaller ones. This mostly had to do with the
search
param not updating properly when cleared.@Kuchenpirat also mentioned in #3332 that persisting state forever seems weird (e.g. if I search for a recipe, then come back to Mealie the next day, I don't really want to see that search again). This moves the search params to session storage so it's cleared when you leave (note: if you just refresh the page it may not look cleared since your query params are there. This behavior is only when navigating back to the home page without query params).
I also refactored a bit and moved default values to an object, since it made some of these changes easier. As a bonus, if we ever implement user-preferred default sorts, this will be very easy to merge in (just load the defaults).
Which issue(s) this PR fixes:
(REQUIRED)
N/A, I'm a little surprised no one's opened an issue for the search being wonky.
Special notes for your reviewer:
(fill-in or delete this section)
Testing
(fill-in or delete this section)
Manually poked around the search a lot.