Next.js Discord

Discord Forum

Prevent parallel route modal from opening on its own page

Unanswered
Zenaida Dove posted this in #help-forum
Open in Discord
Zenaida DoveOP
TL;DR: Is there a way to prevent @modal/my-path from being opened on /my-path?

This is my folder structure:

📂app
├── 📂@modal
│   ├── 📂(.)search
│   │   └── page.jsx // search modal
│   ├── default.jsx // returns null
│   └── page.jsx // returns null
├── 📂search
│   └── page.jsx // search page
└── ...


The "search modal" is accessible from all pages, and there's also a "search page" that serves as a kind of fallback for modal; for example, if the user directly opens mysite.com/search, they should see the "search page".
The problem is that if I go to "search page" and click on the search button (which is a link to /search in header) or change query params (for example: /search?term=something), the "search modal" opens on "search page"!
Is there a way to prevent this behavior?

0 Replies