Skip to content

fix(prefetch): Fix "tap" prefetch strategy when view transitions are enabled - #14235

Merged
martrapp merged 12 commits into
withastro:mainfrom
toxeeec:tap-view-transitions
Oct 9, 2025
Merged

fix(prefetch): Fix "tap" prefetch strategy when view transitions are enabled#14235
martrapp merged 12 commits into
withastro:mainfrom
toxeeec:tap-view-transitions

Conversation

@toxeeec

@toxeeec toxeeec commented Aug 16, 2025

Copy link
Copy Markdown
Contributor

Changes

The "tap" prefetch strategy was the only strategy that didn't call onPageLoad to attach event listeners to new elements. This caused "tap" to only work on the first clicked link when view transitions were enabled.

Testing

New tests are added to e2e/prefetch.test.js that check if each prefetch strategy works correctly with view transitions

Docs

No docs added since this is a bugfix.

@changeset-bot

changeset-bot Bot commented Aug 16, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cfa9165

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 the pkg: astro Related to the core `astro` package (scope) label Aug 16, 2025
@toxeeec toxeeec changed the title Tap view transitions fix(prefetch): Fix "tap" prefetch strategy when view transitions are enabled Aug 16, 2025
@codspeed-hq

codspeed-hq Bot commented Aug 16, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #14235 will not alter performance

Comparing toxeeec:tap-view-transitions (cfa9165) with main (28b2a1d)1

Summary

✅ 6 untouched

Footnotes

  1. No successful run was found on main (3bb14b7) during the generation of this report, so 28b2a1d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ematipico

ematipico commented Aug 21, 2025

Copy link
Copy Markdown
Member

This behavior isn’t explicitly tested. No new tests were added since this PR only unifies "tap" with the other strategies.

It is tested in our e2e testing suite: https://github.com/withastro/astro/blob/main/packages/astro/e2e/prefetch.test.js

Can you please add a new test that covers the fix, please?

@toxeeec

toxeeec commented Aug 30, 2025

Copy link
Copy Markdown
Contributor Author

This behavior isn’t explicitly tested. No new tests were added since this PR only unifies "tap" with the other strategies.

It is tested in our e2e testing suite: https://github.com/withastro/astro/blob/main/packages/astro/e2e/prefetch.test.js

Can you please add a new test that covers the fix, please?

I meant that the exact behavior was not tested (prefetching multiple times with view transitions enabled), but now it is

@ematipico

Copy link
Copy Markdown
Member

It seems that the test isn't passing?

@toxeeec

toxeeec commented Sep 12, 2025

Copy link
Copy Markdown
Contributor Author

It seems that the test isn't passing?

@ematipico should be fixed now

Comment thread packages/astro/src/prefetch/index.ts Outdated
Comment thread packages/astro/src/prefetch/index.ts Outdated
@florian-lefebvre florian-lefebvre added the needs response Issue needs response from OP label Oct 2, 2025
@toxeeec
toxeeec requested a review from martrapp October 9, 2025 04:20

@martrapp martrapp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

and thank you very much for the thorough test coverage!

@martrapp
martrapp merged commit c4d84bb into withastro:main Oct 9, 2025
22 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Oct 9, 2025
florian-lefebvre added a commit that referenced this pull request Oct 13, 2025
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: Matthew Phillips <matthewp@users.noreply.github.com>
Co-authored-by: Houston (Bot) <108291165+astrobot-houston@users.noreply.github.com>
Co-authored-by: Bartosz Kapciak <bartosz.kapciak@swmansion.com>
Co-authored-by: Bartosz Kapciak <martrapp@users.noreply.github.com>
Co-authored-by: Armand Philippot <git@armand.philippot.eu>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Abdelrahman Abdelfattah <spices.digital@gmail.com>
Co-authored-by: Alasdair McLeay <penx@users.noreply.github.com>
Fix failing x-forwarded-host tests (#14505)
fix(prefetch): Fix "tap" prefetch strategy when view transitions are enabled (#14235)
fix `security.allowedDomains` version (#14509)
Fix compatibility with older Astro versions in @astrojs/node (#14514)
Fixes #14513
fix heading level in config reference docs (#14517)
fix(deps): update all non-major dependencies (#14522)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs response Issue needs response from OP pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants