Open joemasilotti opened 8 months ago
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
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.
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