hookrouter icon indicating copy to clipboard operation
hookrouter copied to clipboard

Preserve hash when changing the query params

Open mitchellwarr opened this issue 4 years ago • 0 comments

Currently when you call setQueryParams it clears the current url hash. This is the intended behaviour for history.replaceState as you are most likely changing the pathName. However in the case of setQueryParams, we aren't changing the url location, just the query params. As such, theres no reason the hash should reasonably be wiped.

Here is a change that would preserve not just the pathname on query change, but the hash too.

If hash isnt set, then location.hash is an empty string and causes no issues

mitchellwarr avatar Mar 02 '21 21:03 mitchellwarr