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

Allow multiple push with different state within the same path #2294

Open
sjquant opened this issue Jul 5, 2024 · 1 comment
Open

Allow multiple push with different state within the same path #2294

sjquant opened this issue Jul 5, 2024 · 1 comment
Labels
enhancement New feature or request has workaround A workaround has been found to deal with the issue

Comments

@sjquant
Copy link

sjquant commented Jul 5, 2024

What problem is this solving

Currently, Vue Router prevents pushing the same path multiple times, even if the state differs. This restriction limits the ability to manage state changes effectively within the same route. I propose an enhancement to allow multiple pushes to the same path if the state is different.
me.

Benefits

  • Enhanced state management within the same route.
  • Improved user experience by enabling dynamic updates without altering the URL.
  • Greater flexibility for developers to manage state-specific rendering.

Providing this feature will align Vue Router with modern state management practices and enhance its capabilities in dynamic applications.

Thank you for considering this enhancement. I look forward to your feedback and any further discussion on this proposal.

Proposed solution

Implement a check within the push method to determine if the state has changed. If the state is different, allow the push to proceed even if the path is the same. (maybe check state change in isSameRouteLocation)

Describe alternatives you've considered

As a temporary workaround, we can append a query parameter to the path, but this approach clutters the URL, and there are times when changing URL is not ideal.

@posva posva added enhancement New feature or request has workaround A workaround has been found to deal with the issue labels Jul 7, 2024
@posva
Copy link
Member

posva commented Jul 7, 2024

Currently, you need to add the force: true option to router.push() (or preferably router.replace() for this to work), but it's currently internal and shouldn't be needed correct cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request has workaround A workaround has been found to deal with the issue
Projects
None yet
Development

No branches or pull requests

2 participants