Skip to content

Inconsistent site / back navigation when using useForm #2406

@Mlekar

Description

@Mlekar

Versions:

  • @inertiajs/vue3 version: ^2.0.x

Describe the problem:

Since version 2.x (we're using the Vue3 adapter, but I assume this issue is the same in React and others since the logic is shared), there's been inconsistent behavior when doing back navigation through a site's history.

There are currently two scenarios for how site navigation works, which are different based on whether you're navigating to a page that makes use of the useForm helper with or without a remember key (as described in https://inertiajs.com/forms).

Steps to reproduce:

Scenario 1 (using a remember key):

  1. Start on a page that doesn't make use of a useForm element (for example users.index)
  2. Navigate to a user edit page (via e.g. a table row click, so we land on users.1.edit page, that has a useForm usage like useForm('EditUserForm', { id: props.user.id, name: props.user.name }))
  3. Navigate back (via browser back button) and you will land on the users.index page again as expected
  4. Navigate to another user edit page (e.g. user.2.edit)
  5. When navigating back, you will now land on the user.1.edit page, instead of the expected users.index page
  6. If you navigate back once further, it will completely skip the users.index page, and go back to a previous page

Scenario 2 (not using a remember key)

  1. Once again, start on the users.index page
  2. Navigate to users.1.edit (where we make use of useForm without a rememberKey, so useForm({id: props.user.id, name, props.user.name})
  3. Navigate back, you will land on users.index as expected
  4. Navigate to users.2.edit
  5. Navigate back, you will once again land on users.index as expected
  6. Continue the above pattern infinitely, works as expected

In version 1.x of the InertiaJS library, site navigation always worked the same way as described in scenario 2, which I would say is the expected scenario. If nothing else, an end user would expect the site navigation to behave consistently, regardless if we use the form helper with or without rememberKeys.

Up to version 2.0.13, there was also an issue with the forms misremembering data, but that was fixed in the 2.0.14 version by #2401, so this is the only inconsistency leftover from the 2.x migration that we've detected.

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