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

Do not dispatch multiple visit events on redirect visit #1044

Conversation

domchristie
Copy link
Contributor

@domchristie domchristie commented Oct 24, 2023

#328 fixed an issue with the window's location in native adapters (hotwired/turbo-ios#30 & hotwired/turbo-android#128).

However, proposing a new visit re-runs the visit lifecycle again, duplicating events, and introduced issues such as #428, #526, #537 & #877.

This pull request reverts the visit proposal, and instead updates the location as part of changeHistory(). (This may not have been doable before #601.) It leads to a simpler followRedirect method that now just updates the visit's location. As such, we no longer need the fix from #563.

Fixes #877

@jayohms
Copy link
Collaborator

jayohms commented Oct 26, 2023

As mentioned here #328 (comment) this approach is not compatible with with the iOS/Android Turbo adapters and the way that the libraries work. Avoiding a double-visit on a redirect won't be trivial, so maybe there's another way to approach the issue you're experiencing with the double-visit + animation. Most importantly, though, the mobile adapters need the opportunity to see the redirect url and start a new visit.

@jayohms jayohms closed this Oct 26, 2023
@domchristie
Copy link
Contributor Author

Thanks @jayohms, that definitely clears things up.

I wonder whether there might be another way to model Visit proposals? The Visit class seems to be used as a way to trigger a Visit lifecycle, but this can mean different things in different contexts. For example:

  1. A standard Visit that navigates from one location to the next
  2. A same-page anchor Visit
  3. A redirected Visit
  4. A Frame Visit (promoted to a Visit using data-turbo-action

Each has different expectations and outcomes, which hints that they could be different classes that share the same API

@domchristie
Copy link
Contributor Author

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

Successfully merging this pull request may close these issues.

turbo:visit is dispatched twice on redirect
2 participants