-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
App Dir: Avoid intercepted route for hard navigated page #51648
Comments
I am facing the same issue. Proposition is to have a property <Link href={`/product/${id}`} bypassRouteInterception>See full details</Link> The workaround is:
|
@louisthomaspro The reload workaround works for your use case perfectly. For me, I'm already on the search page. To update the search results, the The page should be intercepted when user is on another route. Once they are on the actual page, there should not be requirement to intercept the same route anymore!!! |
Something like this would be really useful. For my use-case I want the modal to have a |
Am facing the same issue. Looking forward to a fix for this |
Any update on this? I'm using query strings for variant selection on a product page. The product page is being shown in a modal using intercepting routes. When the page is visited directly, selecting a variant causes the modal to be displayed. |
I like that API. Any update? |
Facing the same issue, any update on this. Preferably search params should not trigger the modal to open. |
We need the same functionality. |
anyone found any soludtion . please let me know |
You could use a normal Anchor tag: <a href=href={"/product/" + slug}>View more details</a> |
what if i need to do it with JavaScript i i can use window.location.replace but the main problem is both are making hard reload and broke the single page application experience |
I set it up so the root page triggers the modal. It's not an ideal workaround but at least you don't have the same view rendering on top of itself. I also had to pass in the route to go back to when the modal closes. "use client";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useEffect } from "react";
export default function SearchStocksPage({
searchParams: { query },
}: {
searchParams: { query?: string };
}) {
const pathname = usePathname();
const router = useRouter();
const searchParams = useSearchParams();
let done = false;
useEffect(() => {
if (!done) {
done = true;
router.push(`${pathname}?${searchParams.toString()}`);
}
}, []);
} |
i think i got a solution by making a seperate utility function "use server";
import { redirect } from "next/navigation";
export default async function redirectHard(uri) {
redirect(uri);
} then call it from your client component |
Any workarounds for when url query params are updated (via JS nuqs & non-shallow param replacements)? Currently the only workaround i've found is to redirect to another route.
// app/searchy/page.tsx
import { redirect, RedirectType } from 'next/navigation';
/**
* There is a bug where updating url query params (non-shallow) causes the modal to appear on the full page route.
* https://github.com/vercel/next.js/issues/51648
*
* So we open the modal under /searchy and the full page route for /searchy will soft redirect to /search.
*/
export default function Page(props: any): any {
console.log('searchy page props', props);
const params = new URLSearchParams(props.searchParams);
const newPath = `/search?${params.toString()}`;
redirect(newPath, RedirectType.replace);
} Hacky |
Instead of doing this redirect from server using a server action might be a good option |
I hope that 73390 will be merged, but I’ve discovered a workaround to modify the rewrites in nextConfig. https://www.reddit.com/r/nextjs/comments/174m3xf/comment/k4bhrp2/ |
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #22 SMP Tue Jan 10 18:39:00 UTC 2023 Binaries: Node: 18.14.2 npm: 9.5.0 Yarn: 1.22.19 pnpm: N/A Relevant packages: next: 13.4.7-canary.4 eslint-config-next: 13.4.7 react: 18.2.0 react-dom: 18.2.0 typescript: 5.0.4
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/dazzling-hooks-fz6pjv
To Reproduce
The search modal should not show up.
Describe the Bug
/search
route in a ModalAll Good so far.
/search?q=food
/search
route in a ModalSince the user is already on the full
/search
page, there should not be any requirement to again open the intercepted routeExpected Behavior
When updating the route with a new query string, the page should get updated and not show the intercepted route modal. As the page is already loaded and should not be again intercepted.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: