stencil-community / stencil-router

A simple router for Stencil apps and sites
https://stenciljs.com/
MIT License
189 stars 55 forks source link

Hash change event not firing #106

Open Flowrome opened 4 years ago

Flowrome commented 4 years ago

Stencil version:

 1.8.1

I'm submitting a ... (check one with "x") [x] bug report [ ] feature request [ ] support request

Current behavior: When using hashchange listener with historyType="browser" the event is not firing:

<stencil-router historyType="browser">
...
</stencil-router>

private hashChangeHandler(): void {
window.addEventListener('hashchange', (e) => {
      console.log(e)
    })
}

Expected behavior: even if i use the browser navigation the hashChange listener should work

Steps to reproduce: Just start a Stencil application with stencil router and navigate programmatically on a route with an hash and add a hashchange listener.

Thank you for your work.

Romeo Nupieri

threeaccents commented 4 years ago

I'm on the same boat. In the mean time if you want you can just use a regular a tag as it won't cause a page reload if you're just updating the hash