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

goBackN()? #765

Closed
Zinggi opened this issue Feb 4, 2015 · 2 comments
Closed

goBackN()? #765

Zinggi opened this issue Feb 4, 2015 · 2 comments

Comments

@Zinggi
Copy link

Zinggi commented Feb 4, 2015

I do have a site where you can open a popup. From this popup you can navigate deeper.
I mapped all those subpages of the popup to the url and that works great.

What I want to do now is close this popup, e.g. navigate a certain amount of steps back.

I implemented goBackN(n) myself by just calling goBack() n times.
This works on chrome, but not on android and ios. There it only goes back once, ignoring the repeated calls.

transitionTo(...) doesn't work either in my case, see illustration below:

app/foo
app/foo/popup      #open popup
app/foo/popup/1    #navigate deeper
app/foo/popup/1/2  #navigate deeper
app/foo            #close the popup using transitionTo('foo')
app/foo/popup/1/2  #user pressed browser back button, NOT what I want
                   #correct would be: "app"

What other options do I have? Can I use transitionTo(...) and then directly modify the history somehow?

@agundermann
Copy link
Contributor

If you know the exact amount of steps to go back, and if you use HistoryLocation, I think right now it would be easiest to bypass the router: window.history.go(-n).

@Zinggi
Copy link
Author

Zinggi commented Feb 4, 2015

Thanks a lot for your very quick response, this works fine!

But it seems a bit hacky to bypass the router, can this potentially cause any problems in the future?

I'm closing this now, as it currently works for me.
But maybe this use case should be implemented in react router, as others might run into the same problem?

@Zinggi Zinggi closed this as completed Feb 4, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 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