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

View transitions: transitionEnabledOnThisPage returns true when fallback is set to none #11528

Closed
1 task done
bholmesdev opened this issue Jul 22, 2024 · 9 comments
Closed
1 task done
Labels
- P2: has workaround Bug, but has workaround (priority) feat: view transitions Related to the View Transitions feature (scope)

Comments

@bholmesdev
Copy link
Contributor

Astro Info

Astro                    v4.11.5
Node                     v20.13.1
System                   macOS (arm64)
Package Manager          pnpm
Output                   hybrid
Adapter                  @astrojs/netlify
Integrations             @astrojs/markdoc
                         astro-icon
                         @astrojs/react
                         simple-stack-query

If this issue only occurs in one browser, which browser is a problem?

Firefox, Safari

Describe the Bug

I built a library that reruns a user's script whenever view transitions are enabled. I toggle this behavior using transitionEnabledOnThisPage from astro:transitions/client. However, I noticed this returns true even when fallback is set to none and my browser does not support view transitions.

What's the expected result?

I am using transitionEnabledOnThisPage to determine whether the astro:page-load event will fire. Since astro:page-load does not fire when the fallback is set to none, I would expect transitionEnabledOnThisPage to return false.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-gcu7qh?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@martrapp
Copy link
Member

Hi @bholmesdev, yes, in retrospective one might expect that ;-)
I'm a bit reluctant to change the semantics of the API but on the other hand,
a) I do not think that that this function is widely used and
b) one might argument that it is a bug

Would be happy to see your PR on this!
Should we defer it to 5.0?

In the meanwhile you could extend your test with && ... getFallback() !== 'none')

@martrapp martrapp removed the needs triage Issue needs to be triaged label Jul 24, 2024
@bluwy bluwy added - P3: minor bug An edge case that only affects very specific usage (priority) feat: view transitions Related to the View Transitions feature (scope) labels Jul 24, 2024
@bholmesdev
Copy link
Contributor Author

bholmesdev commented Jul 24, 2024

I was unaware we had a getFallback()! I queried for the meta tag directly as a workaround. That should also suffice. Don't feel too strongly, but I do think "transition enabled" means "SPA routing" for my use cases.

If I were to make a PR, it would just add that getFallback() check. I can raise as a 5.0 item.

@martrapp
Copy link
Member

Yes, please! Regarding the original intend you could talk to Matthew.

Inside the client side router it is not used as "SPA-mode" but "The client-side router code is available on that page in case we need to reload".

I skimmed our uses and it looks like adding getFallback() !== "none" wouldn't hurt, but you should check it thoroughly. I'm afraid we do not have e2e tests that check consequences in the behavior when transitionEnabledOnThisPage changes. 🙄

Alternatively, you could add a new function along the lines of "SPA routing".

@martrapp martrapp added - P2: has workaround Bug, but has workaround (priority) and removed - P3: minor bug An edge case that only affects very specific usage (priority) labels Jul 29, 2024
@matthewp
Copy link
Contributor

@martrapp is this something we can still do for 5.0? It doesn't break internal expectations?

@martrapp
Copy link
Member

Yes, I guess, we can. But I only skimmed through the uses.
Changing the documented semantics would also need a docs update.
@bholmesdev, still want to PR this?

@martrapp
Copy link
Member

Having a second look at the whole thing:

@bholmesdev, @matthewp: Even though I can understand when reading the name of the function raises expectations that it might do something else, I guess we should have better justification for an incompatible change to a published function. People might have used it in their own components to differentiate as the docs suggest.

@martrapp
Copy link
Member

Hi @bholmesdev, this issue has been sitting here for quite a while.
I would like to close it as the behavior fits the documentation.
Do you still plan to open a PR (core + docs)?

@matthewp
Copy link
Contributor

I think we can close.

@bholmesdev
Copy link
Contributor Author

@matthewp agreed. I don't feel strongly enough to push this forward, and I no longer use the function in my own code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority) feat: view transitions Related to the View Transitions feature (scope)
Projects
None yet
Development

No branches or pull requests

4 participants