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

Pages don't reload when redirecting out of modals #47

Open
ajdubovoy opened this issue Nov 13, 2024 · 4 comments
Open

Pages don't reload when redirecting out of modals #47

ajdubovoy opened this issue Nov 13, 2024 · 4 comments

Comments

@ajdubovoy
Copy link

Hi team, first of all congrats on launching v1.0. It's really been a pleasure migrating from the old package. I noticed a small bug I haven't been able to resolve yet in our app that I thought I'd raise an issue about since if might affect others. In our paths, I put something like:

  -
    patterns:
      - "^/users.*" # Enable to put login screen in a modal
    properties:
      context: modal
      presentation: replace
      pull_to_refresh_enabled: false

This works quite well to put out sign-in and sign-up pages (which are managed through devise) in a modal. The interface of that feels a bit more "native-ish" than if these pages are just loaded in the inline stack. And it does work sometimes.

But frequently, I get an issue where, after successfully signing in, hotwire-native closes the modal totally fine. But if the sign in redirects back to the page that was open underneath the modal, that page doesn't always refresh. Sometimes it does, so I'm a bit confused since the behavior isn't consistent. But it often doesn't.

I'm not 100% sure whether it's a framework error or just me being a more experienced Rails dev than a Swift one. But my instinct is that, if a modal triggers a redirect to a page that's already open under the modal context, that page should always get reloaded, no?

Thanks so much for your help and awesome work on this project!

@joemasilotti
Copy link
Member

Thanks for the kind words! It's awesome to hear you've been enjoying the new framework.

The modal is dismissed because a new page is requested. If that new page does not have context set to modal then Hotwire Native will dismiss the modal and load the new page.

Any time Hotwire Native loads a new page it first checks to see if the current page matches the URL of the new one exactly. If so, it will replace said page, which looks like it is reloading it when being dismissed from a modal.

My guess is that sometimes you are redirecting to a new page after signing in and sometimes you are redirecting back to the original non-modal page. Feel free to post more of the Rails code, if possible, and I can help debug.

@ajdubovoy
Copy link
Author

Hi! Maybe I should clarify the problem a little better

  1. User clicks the sign in button
  2. Modal opens
  3. User fills in details and pushes submit
  4. Rails triggers redirect. Modal closes (this is expected)
  5. The page "underneath" the modal does not refresh. The replace action seems not to be triggered. So, the user can't actually see they're successfully signed in until they click on a link, and then everything is fine once they start opening other pages.

I'm super happy to share whatever code would be helpful. Thank you so much for your time!

@ajdubovoy
Copy link
Author

I've temporarily turned the modal presentation off in our paths and, without it, everything works totally fine.

@joemasilotti
Copy link
Member

Interesting! Can you enable logging and share what shows up when you trigger the flow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants