-
-
Notifications
You must be signed in to change notification settings - Fork 3k
fix: emit hashchange events with view transitions
#14746
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 2d29da4 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
CodSpeed Performance ReportMerging #14746 will not alter performanceComparing Summary
Footnotes |
hashchange events with view transitions
|
Hi @destruc7i0n 👋🏼 Thank you for opening this PR! |
| scrollTo({ left: 0, top: 0, behavior: 'instant' }); | ||
| } | ||
| } | ||
| if (intraPage && from.hash !== to.hash) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the client router, a navigation from /long-page#click-one-again to /long-page won't dispatch a hashchange event.
Also doing a history backward traversal from /long-page to /long-page#click-one-again won't dispatch the event.
To mimic standard browser behavior that developers already expect, we should exclude the event for a navigation to an URL without fragment identifier and for backward traversal from an URL without fragment identifier? 🤓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm true. Seems like the browser itself is emitting a hashchange event with the backwards traversal from /long-page to /long-page#click-one-again so I'll need to take a look at how to stop that 🤔
Changes
hashchangeevents are now emitted when navigating between hash anchors on the same page (e.g., clicking anchor links)oldURLandnewURLproperties matching standard browser behaviorTesting
view-transitions.test.js:hashchangefires for same-page hash navigationhashchangefires for back/forward navigation with hasheshashchangedoes NOT fire for cross-page navigationDocs
I don't think any are required. This implements standard browser behavior that developers already expect.