qwik icon indicating copy to clipboard operation
qwik copied to clipboard

Fire the hashchange event even if the navigation changes only `location.hash`

Open genki opened this issue 11 months ago • 6 comments

What is it?

  • Bug fix

Description

I am making an app with Qwik that is using SPA navigation between pages including URL fragment. Currently, the SPA navigation doesn't fire the hashchange event if the change of URL is only the hash fragment because it is using history.pushState. This is not the standard behaviour of the browser.

So I have changed this

  • only if the change is consist of the fragment of URL.
  • then navigate by using location.hash = ... due to fire the hashchange event.

Checklist

  • [x] My code follows the developer guidelines of this project
  • [x] I performed a self-review of my own code
  • [ ] I added a changeset with pnpm change
  • [ ] I made corresponding changes to the Qwik docs
  • [ ] I added new tests to cover the fix / functionality

genki avatar Feb 10 '25 21:02 genki

⚠️ No Changeset found

Latest commit: c9054a895eb5168126bc290d811ef2e3a5e28afc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Feb 10 '25 21:02 changeset-bot[bot]

Open in Stackblitz

npm i https://pkg.pr.new/@builder.io/qwik@7329
npm i https://pkg.pr.new/@builder.io/qwik-city@7329
npm i https://pkg.pr.new/eslint-plugin-qwik@7329
npm i https://pkg.pr.new/create-qwik@7329

commit: e2dd128

pkg-pr-new[bot] avatar Feb 10 '25 23:02 pkg-pr-new[bot]

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview c9054a895eb5168126bc290d811ef2e3a5e28afc

github-actions[bot] avatar Feb 10 '25 23:02 github-actions[bot]

it would be great if you add a test for it

JerryWu1234 avatar Feb 11 '25 05:02 JerryWu1234

@genki Could you add a test for it ?

JerryWu1234 avatar Feb 26 '25 02:02 JerryWu1234

@JerryWu1234 Sorry currently I can't take a time for a while 🥲

genki avatar Feb 26 '25 17:02 genki