Modals stays open after push
Unanswered
patrick.py posted this in #help-forum
Hi folks, I'm not sure I'm understanding this correctly, but I basically have a model that intercept a route (/new) and when I create an checkin (see video) I do a redirect to the checkin page, but the modal stays up, I'm not sure this is expected?
14 Replies
I've opened an issue: https://github.com/vercel/next.js/issues/68687
That isn't an issue. In fact when you navigate between pages your modal state havent change. You need to close it your self at the form submit
If you do an @modal that means it shared between pages. To avoid unexpected rerender the modal state wont change when you navigate
my thoughts on this are, I'm using an intercept to show the modal, when the intercept doesn't apply anymore then the modal shouldn't be shown anymore
just like when go you back
The fact is the @ in app dir is used to share componant between pages. Your intercept still exist so!
The @ create "Slots". These slots are passed as props to shared parent layout which means your main layout got your modal. So, if you navigate between pages the main layout still have the modal component
@patrick.py any update?
@ItetsuLaTable <@103046425952124928> any update?
I did what you told me 😄 and manually close the modal, but still doesn’t feel right to me 😄
The fact is the intercept create that modal as a slot and it will share in the whole project.
So even if the intercept is gone your modal stay there because of it
So even if the intercept is gone your modal stay there because of it
@ItetsuLaTable The fact is the intercept create that modal as a slot and it will share in the whole project.
So even if the intercept is gone your modal stay there because of it
so I've done this, but I just realise that since the component is still there, going back to it will keep the modal closed 😐