Skip to content
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

Fix history navigation to hash fragment on Firefox when using view transitions #9563

Merged
merged 3 commits into from
Jan 2, 2024

Conversation

martrapp
Copy link
Member

@martrapp martrapp commented Jan 1, 2024

Changes

Firefox clears the history state on same page navigation, which later breaks history navigation.
This fix prevents that.
From discord user mcoms on #support > View Transitions back/forward not working in Firefox for fragment links:

In Firefox, on all ViewTransition fallbacks but none, going back to a fragment link (#about) from another page does not work. It stays on the current page without navigating back. For example, if I have a page with a link /#about and then I go to /faq, I press back and the URL changes to /#about but the content is still /faq. This happens until I reach that does not contain a # in the URL, or if the # was initially navigated to. It even doesn't work if the # link had data-astro-reload={true}.

SvelteKit had a similar issue.
Their analysis put me on the right track.

Testing

Tested manually on Firefox as we do not run automated e2e tests on Firefox.

Docs

n/a bug fix.

Copy link

changeset-bot bot commented Jan 1, 2024

🦋 Changeset detected

Latest commit: 5aee87b

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

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels Jan 1, 2024
"astro": patch
---

Fix history navigation to hash fragment on Firefox when using view transitions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Fix history navigation to hash fragment on Firefox when using view transitions
Fixes history navigation to hash fragment on Firefox when using View Transitions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we were deliberately using the imperative form?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the opposite 🤔 we need Sarah (on phone rn, I can't ping for some reason)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarah11918 to the rescue!

@martrapp martrapp merged commit d48ab90 into main Jan 2, 2024
13 checks passed
@martrapp martrapp deleted the mt/firefox_intra_page branch January 2, 2024 21:18
@astrobot-houston astrobot-houston mentioned this pull request Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants