Skip to content

Behavior when transitioning to same path #826

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

Closed
agundermann opened this issue Feb 12, 2015 · 10 comments
Closed

Behavior when transitioning to same path #826

agundermann opened this issue Feb 12, 2015 · 10 comments
Labels

Comments

@agundermann
Copy link
Contributor

Right now, when clicking a link to the currently active path, the browser will

  • create a new history entry (HistoryLocation)
  • not create a new history entry (HashLocation)
  • not "refresh" the page by calling the run callback

On static web sites, all the browsers I tested do refresh the page, but they don't create new history entries, so I think we should do this, too. Or at least make HistoryLocation and HashLocation consistent.

@gaearon
Copy link
Contributor

gaearon commented Mar 4, 2015

How do you tell it creates a new entry? I click many times on current page's link in my app and I can go back in a single Back click.

@agundermann
Copy link
Contributor Author

I click many times on current page's link in my app and I can go back in a single Back click.

That's not what I'm observing at http://react-router-mega-demo.herokuapp.com/ with either Chrome, Firefox or IE. Are you sure you tried with HistoryLocation?

@gaearon
Copy link
Contributor

gaearon commented Mar 22, 2015

Sorry, indeed you're right. I verified on HashLocation by mistake!

@RickWong
Copy link

@taurose Did you find a work-arround?

@agundermann
Copy link
Contributor Author

I've been meaning to create a PR but haven't gotten around to it yet.

I don't think there's a simple and clean way to get the always-refresh behavior. As for not creating new history entries for HistoryLocation, you should be able to intercept HistoryLocation.push():

HistoryLocation._push = HistoryLocation.push;
HistoryLocation.push = function(path){
  if(path !== HistoryLocation.getCurrentPath())
    HistoryLocation._push(path);
}

@RickWong
Copy link

✅ Thanks @taurose, it works!

@darrenmce
Copy link

not create an additional history entry if path has not changed (HistoryLocation and TestLocation)

+1

thanks for workaround in the meantime!

@ryanflorence
Copy link
Member

I imagine we still have this issue on master

@mjackson mjackson added this to the 1.0.0 milestone Jun 30, 2015
@ryanflorence
Copy link
Member

@taurose @mjackson please reopen if I'm wrong, but I think your work on history defined this stuff.

@refacrot
Copy link

hey guys, what about this:

not create an additional history entry if path has not changed (HistoryLocation and TestLocation)

I'm on react-router 1.0.0-rc3 + "history/lib/createBrowserHistory" and this problem still appears for me.
Thanks.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants