Skip to content

Unexpected behavior with clear_all and replace_root #115

@leonvogt

Description

@leonvogt

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("/")
})
  1. Navigate to /one (title: "Navigate to another page")
  2. 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

  1. 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"
  }
},
  1. Navigate to /one
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions