Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Recipe Search URL State #3332

Conversation

michael-genson
Copy link
Collaborator

What type of PR is this?

(REQUIRED)

  • bug
  • feature

What this PR does / why we need it:

(REQUIRED)

This fixes a bunch of issues with the homepage's recipe search and URL state. Namely:

  • The URL always reflects the current search params
  • Navigating directly to a URL with search params will correctly apply those search params
  • If already on the homepage, clicking on the Mealie logo will reset your search params (and correctly show all recipes)
  • Clicking on a tag will correctly update your search params
  • Clicking on a tag as a public user sets your tag filter (this was previously only a feature for logged-in users)
  • The "created at" param is no longer always shown in the URL (this issue was due to a misused camelCase param, whereas all search params use snake_case)

This also adds a user state for the last set of search params, i.e. next time you open Mealie your last search will be restored. There are two exceptions to this:

  1. If you're already on the home page, and you click the Mealie logo, your last search is ignored, and your filters are reset
  2. If you navigate to the home page and provide query params (e.g. https://MyMealieSite.com/g/home?tags=abc-123) then the query params are respected, and your last search is ignored

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #2447
Fixes #2352
Fixes #2259
Fixes #931

Testing

(fill-in or delete this section)

Lots of clicking

- update state when there are no query params
- only call search if the query params actually changed
- wait until ready to call API
@Kuchenpirat Kuchenpirat self-assigned this Mar 25, 2024
Copy link
Collaborator

@Kuchenpirat Kuchenpirat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks a big search improvement 🚀🚀

Only thing holding me up from merging is that the query is also applied after i close and reopen the page.
Imagine the situation: I use mealie to cook todays dinner. Afterwards i close the page. Tomorrow i navigate to mealie.example.com, but instead of landing on the home page with all my recipes, the search with the same querry parameters is opened.

This seems quite contra-intuitive to me.

@@ -9,7 +9,7 @@
color="accent"
:small="small"
dark
:to="isOwnGroup ? `${baseRecipeRoute}?${urlPrefix}=${category.id}` : undefined"
:to="`${baseRecipeRoute}?${urlPrefix}=${category.id}`"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chip stays clickable if the user is not allowed to access the RecipeExplorerPage which will then just redirect to login.
This happens if the group is private and the recipe is accessed via a shared link by a non logged in user.

So it is pretty niche occurance.

@hay-kot hay-kot enabled auto-merge (squash) March 25, 2024 16:00
@hay-kot hay-kot merged commit dfbc890 into mealie-recipes:mealie-next Mar 25, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants