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

Feature request: Add a way to add url hash fragments to pages when visiting via browser.to(page) #463

Closed
tomdcc opened this issue Dec 23, 2016 · 2 comments
Assignees
Milestone

Comments

@tomdcc
Copy link

tomdcc commented Dec 23, 2016

We have a SPA that keeps some state in the browser hash, e.g. http://foo.com/page-uri?searchparam=value#focusedElement=bar.

I just hit a case of wanting to visit a page with some state pre-specified in the URL, but found that there's no way to do this using the normal browser.to(page) pattern. The fallback is to construct the page url manually and then use browser.go(theUrl); browser.at(page), but this is a bit ugly.

This could take the form of duplicated to() / via() methods with an extra param on the end for the hash. One annoyance is that it would read weirdly, since the params map is currently the last one:

browser.to(myPageClass, [subpath], 'hashfoo=bar', param: 'baz')

Alternatively, the new form could force API consumers to just put their params in a map in the natural order, which would make readability a bit better

browser.to(myPageClass, [subpath], [param: 'baz'], 'hashfoo=bar')

A different approach could be to use a magic key and pass the hash as a param:

browser.to(myPageClass, [subpath], param: 'baz', (Browser.HASH): 'hashfoo=bar')

Another thing to consider would be allowing the hash to be specified as a map, as this is quite common for SPAs:

browser.to(myPageClass, [subpath], [param: 'baz'], [hashfoo: 'bar'])

@erdi
Copy link
Member

erdi commented Dec 23, 2016 via email

@erdi
Copy link
Member

erdi commented Dec 29, 2016

Hopefully that's what you were after, @tomdcc.

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

No branches or pull requests

2 participants