momentum-modal icon indicating copy to clipboard operation
momentum-modal copied to clipboard

Redirecting from one modal to another

Open grantholle opened this issue 2 years ago • 10 comments

I've got two modals that share the same base url/route. In one modal, I'm making doing a form.put(), where the redirect should be a new modal.

It's currently sending the right redirect response from the first (as far as I can tell), and is GET calling the correct url of the second modal, but then it immediately GETs the base url.

Screen Shot 2022-09-26 at 11 38 43 AM

grantholle avatar Sep 26 '22 07:09 grantholle

In my PUT action, if I return Inertia::location($mySecondModalUrl) it does load the second modal page without immediately going to the base url. Not ideal, but it achieves the functionality.

grantholle avatar Sep 26 '22 07:09 grantholle

IMO you should stick to 1 route = 1 modal, since that's the point of the package.

lepikhinb avatar Sep 30 '22 04:09 lepikhinb

Do you mean 1 route = 1 base url? Because my modals are on different routes.

grantholle avatar Sep 30 '22 04:09 grantholle

Or one modal per base route is more accurate.

My modals are on different routes, but they all share the same base url.

grantholle avatar Sep 30 '22 04:09 grantholle

Ah, I probably misread the message. I'm going to investigate the issue soon. It would help a lot if you can set up a reproduction repository.

lepikhinb avatar Sep 30 '22 04:09 lepikhinb

Sure, I will try recreate it

grantholle avatar Sep 30 '22 04:09 grantholle

Can confirm. Reproduction repo: https://github.com/lumore/momentum-modal-navigation-issue-example

lumore avatar Oct 01 '22 16:10 lumore

I'm having a very similar issue. I have a link that go to the "forgot password" modal image

If I click on the forgot password link, the route redirects to the right route. But It doesn't do anything. If I click a second time: The forgot password modal loads :

image

Same thing on my register modal. I have a link "Already registered?" that goes to the login modal but I have to click 2 times for it to load

fira03079508 avatar Oct 01 '22 22:10 fira03079508

I have encountered the same problem. In my case, the "X-Inertia-Modal-*" headers were not set. So it is clearly an axios problem. After I corrected the axios version as suggested in the installation instructions, it worked.

I think this can be closed but maybe the documentation could address this clearly.

wPatrick avatar Oct 17 '22 12:10 wPatrick

I'm aliasing axios, so everything that needs it is using the same version.

export default defineConfig({
  resolve: {
    alias: {
      axios: path.resolve(__dirname, 'node_modules/axios/dist/axios.js'),
    }
  },
  //
})

grantholle avatar Oct 17 '22 12:10 grantholle

👀

emargareten avatar Jan 08 '23 19:01 emargareten

You should use the same version of axios as Inertia uses, that's written in docs. This should fix the problem.

Warning The package utilizes axios under the hood. If your app is already using axios as a dependency, make sure to lock it to the same version Inertia uses.

npm i [email protected]

lumore avatar Jan 08 '23 19:01 lumore

@lumore Not if you use an alias as mentioned in my previous comment.

I encountered an issue with Axios interceptors as discussed here, and if you correctly alias Axios, it resolves the issue.

grantholle avatar Jan 09 '23 04:01 grantholle

@lumore thanks for the clarification

@grantholle feel free to re-open the issue if the problem persists

The package has just been updated to support Inertia.js v.1.0. Make sure to update to the latest version.

lepikhinb avatar Jan 22 '23 23:01 lepikhinb