Skip to content

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

@tomdcc

Description

@tomdcc

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'])

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions