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

Visiting same page doesn't replace on stack #27

Open
joemasilotti opened this issue Apr 2, 2024 · 2 comments
Open

Visiting same page doesn't replace on stack #27

joemasilotti opened this issue Apr 2, 2024 · 2 comments
Assignees

Comments

@joemasilotti
Copy link
Member

In Hotwire Native iOS, visiting the same page that is currently being displayed will automatically replace it. On Hotwire Native Android, this pushes a new screen onto the stack.

Same is true for when visiting a page that is exactly the same as the previous one on the stack.

Here is the relevant iOS code that handles both of these scenarios:
https://github.com/hotwired/hotwire-native-ios/blob/main/Source/Turbo/Turbo%20Navigator/TurboNavigationHierarchyController.swift#L114-L131

@jayohms
Copy link
Contributor

jayohms commented Apr 5, 2024

Thanks, this is surprising 🤔. I'll have to look into it. That's not how it's designed to work:
https://github.com/hotwired/hotwire-native-android/blob/main/core/src/main/kotlin/dev/hotwire/core/turbo/nav/TurboNavRule.kt#L73-L74

@joemasilotti
Copy link
Member Author

My mistake! The library is indeed replacing the screen when the same page is visited.

However, it plays the same animation as if you were pushing a new screen on the stack. Which confused me.

It seems that the correct animation plays when using data-turbo-action="replace" and when visiting the same page via a link tap. But it plays the "wrong" animation when submitting a form that navigates to the same page that was previously shown.

You can replicate this in the demo server with the following diff:

diff --git a/server.js b/server.js
index bd40580..e1e9dad 100644
--- a/server.js
+++ b/server.js
@@ -88,7 +88,7 @@ app.get("/new", (request, response) => {
 })

 app.post("/new", (request, response) => {
-  response.redirect("/success")
+  response.redirect("/")
 })

 app.get("/strada-form", (request, response) => {

Then tapping "Load a webpage modally" and then "Submit Form". The home page should animate in via a fade animation but instead is pushed onto the stack.

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