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

If validateSearch rewrites URL, router nav works but initial load fails (with strange behavior) #1928

Closed
bhaugeea opened this issue Jul 9, 2024 · 1 comment · Fixed by #1907
Labels
bug Something isn't working

Comments

@bhaugeea
Copy link
Contributor

bhaugeea commented Jul 9, 2024

Describe the bug

If the validation function not only validates but also returns something other than what it got (e.g. get empty input, return object with defaults), then the URL gets rewritten and page load fails. When using router navigation the URL is not rewritten and page load is successful.

What I mean by "page load fails": Not sure exactly what is going wrong, but in my repro the manifestation is that throw notFound() gets ignored and the route's match status is erroneously "success".

The repro uses a validateSearch function from the docs so I assume it's supposed to work.

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-uyzm48?file=src%2Froutes%2Fposts.%24postId.tsx

Steps to Reproduce the Bug or Issue

  1. Use one of the links to get to a /posts/<something> route (WORKS)
  2. Refresh (DOESN'T WORK)
    • See that it was automatically rewritten to /posts/<something>?page=1&filter=&sort=newest (I think this is the thing that isn't handled well)
  3. Refresh again (WORKS)
    • It wasn't rewritten this time because it was already filled

Expected behavior

Full page load and router navigation should share the same URL rewriting (or non-rewriting) behavior. They should result in the same page behavior as well. A validateSearch function that returns extra defaults or something else not strictly the same as its input should not cause a throw notFound() error to be ignored or any other strange behavior.

Screenshots or Videos

No response

Platform

  • OS: Windows
  • Browser: Chrome
  • Version: 126.0.6478.127

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
3 participants