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

Don't add new location to history when navigating to the current URL #5039

Closed
rhernandog opened this issue Apr 26, 2017 · 1 comment
Closed

Comments

@rhernandog
Copy link

Version

4.1.1

Test Case

https://reacttraining.com/react-router/web/example/basic

Steps to reproduce

Click on the "About" link several times, the the previous button

Expected Behavior

If the Link's to param is the current history location pathname, don't push it to the history, so if the user clicks the back button, it actually goes back to the previous component, not the current one again.

Actual Behavior

The history object keeps pushing the same url over and over, so if you click the previous button the same component is rendered again. I understand that there could be some other params on the url, so the question also would be, is there too much code and performance overhead on adding a regex check in order to see if the url location is the same and use the rest of the params for the intend purposes?

@pshrmn pshrmn changed the title Don`t add to history the current URL Don't add new location to history when navigating to the current URL Apr 26, 2017
@pshrmn
Copy link
Contributor

pshrmn commented Apr 26, 2017

The current behavior is definitely intentional because there is a test case that verifies that a new location is created when navigating to the same path. However, I'm not sure exactly what the rationale behind that is.

I'm going to close this in favor of moving this issue to the history repo. It would be more appropriate there because that is what actually handles location changes.

@pshrmn pshrmn closed this as completed Apr 26, 2017
skindstrom added a commit to skindstrom/4temps-tournament that referenced this issue Dec 24, 2017
Previously, it did not open in a new tab.
Now it does.

However, this introduces a regression that was fixed in 97a54bd
Now if a user clicks on 'Create Tournament' when at /create-tournament,
and then tries to press back, the user will still be at
/create-tournament until the user presses back again.

Personally I feel as if browsing back through the history is less
of an issue compared to non-standard ctrl-click behaviour.

The issue with react-router Link pushing the same path multiple times
can be tracked in:
remix-run/react-router#5039
remix-run/history#470
@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants