-
Notifications
You must be signed in to change notification settings - Fork 24
Description
I've noticed some behavior with clear_all
and replace_root
that I didn't expect.
Related Issues on the iOS side: hotwired/hotwire-native-ios#107
Replace root
Steps to reproduce:
Ensure the Demo app has the following path configuration snippet (should be included by default):
{
"patterns": [
"^$",
"^/$"
],
"properties": {
"presentation": "replace_root"
}
},
Update the server.js file of the Demo Server like this:
app.get("/two", (request, response) => {
- response.render("two", { title: "Push or Replace?", action: request.query.action })
+ response.redirect("/")
})
- Navigate to /one (title: "Navigate to another page")
- Navigate to /two (title: "Advance to another webpage")
Expected Server Logs:
GET /one
GET /two
GET /
Actual Server Logs:
GET /one
GET /two
GET /
GET /
The routing documentation states that replace_root
will:
Dismiss if modal screen then
Pop to root then
Replace root screen on main stack
The root screen route is loaded twice.
This might be intended behavior, but my expectation was that the root screen would only be loaded once.
Clear all
- Add the following to the path configuration to use /two as a
clear_all
route:
{
"patterns": [
"^/two$"
],
"properties": {
"uri": "hotwire://fragment/web/home",
"presentation": "clear_all"
}
},
- Navigate to /one
- Navigate to /two
Expected Server Logs:
GET /one
GET /two
GET /
Actual Server Logs:
GET /one
GET /two
The documentation states that clear_all
will:
Dismiss if modal screen then
Pop to root then
Refresh root screen on main stack
The app pops to the root but doesn’t reload the root screen.
I expected the root screen to reload after navigating to /two to refresh it. But maybe I misunderstood what "refresh" means in this context.
Note: In the related iOS issue I've described an unexpected behavior with Redirecting to a clear_all route.
This is not needed here because, on Android, redirecting to a clear_all
route behaves the same as navigating to it, like above.