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

replaceRoute API support request? #9

Open
albertalquisola opened this issue Feb 3, 2017 · 5 comments
Open

replaceRoute API support request? #9

albertalquisola opened this issue Feb 3, 2017 · 5 comments

Comments

@albertalquisola
Copy link

albertalquisola commented Feb 3, 2017

Any chance we can get support for a call that looks something like this?

// does not add an entry into the browser history
router.replaceRoute('/new/route');

Under the hood, director is using window.pushState() on the router.setRoute() call which will push a new entry onto the window history stack. This makes the native browser history inflexible in certain cases.

eg. if i only want to change query params (user isn't taken to new page)
previous url: example.com/home
current url: example.com/new/route
router.setRoute('/new/route?new=true');

Now, if the user clicks back button, they'll be taken to example.com/new/route which is the same page sans any query param filter. I would like the control to navigate them back to example.com/home instead.

Also, this has been requested by a few of people:
flatiron#316

@SpaceK33z
Copy link

Fair enough. Would you be interested in making a PR?

@albertalquisola
Copy link
Author

albertalquisola commented Feb 3, 2017

Potentially. However, I'm not overly familiar with how to replicate this behavior in legacy browsers (browsers that dont support window history API)

@albertalquisola
Copy link
Author

I went ahead and wrote a quick implementation for replaceRoute. Mind adding me as a collaborator so I can submit a PR? I cant push my branch up due to insufficient permissions.

@SpaceK33z
Copy link

That shouldn't be necessary, if you go to the Pull Requests page in this repo, you can click "New pull request" and select your own fork.

@albertalquisola
Copy link
Author

cool, thats fine. just submitted a PR. This is more a proof of concept. If you like the approach, I can refine/refactor a bit more and add test cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants