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

svelte {@html} not reactive since Astro view transitions enabled #10725

Closed
1 task
mef opened this issue Apr 9, 2024 · 7 comments
Closed
1 task

svelte {@html} not reactive since Astro view transitions enabled #10725

mef opened this issue Apr 9, 2024 · 7 comments
Labels
needs response Issue needs response from OP

Comments

@mef
Copy link

mef commented Apr 9, 2024

Astro Info

Astro                    v4.5.17
Node                     v20.6.1
System                   Linux (x64)
Package Manager          unknown
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/svelte
                         astrojs-service-worker

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

N/A

Describe the Bug

The @html svelte directive is not reactive when Astro view transitions are enabled.

This happens for a variable someVariable getting its value from a Svelte store. A component displaying someVariable is used across multiple pages.

{@html someVariable} is correctly updated whenever `someVariable changes in a page.

However, when navigating across pages, which contain the component, {@html someVariable} is not shown in the destination page. If I swap it with a {someVariable}, then the correct content is displayed.

The problematic code was working perfectly fine with Astro 2.x, before view transitions were activated (i.e. with full page navigation).

What's the expected result?

{@html someVariable} correctly renders the variable content after navigating to the page via a hyperlink, when astro view transitions are enabled.

Link to Minimal Reproducible Example

https://codesandbox.io/p/devbox/mutable-sky-59glz7?file=%2FREADME.md

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Apr 9, 2024
@matthewp
Copy link
Contributor

matthewp commented Apr 9, 2024

I think your devbox is private. Please make it public or use one of these templates: https://astro.new/latest

@matthewp matthewp added needs repro Issue needs a reproduction and removed needs triage Issue needs to be triaged labels Apr 9, 2024
Copy link
Contributor

github-actions bot commented Apr 9, 2024

Hello @mef. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@mef
Copy link
Author

mef commented Apr 9, 2024

I think your devbox is private. Please make it public or use one of these templates: https://astro.new/latest

Thanks, indeed, the URL was incorrect. I just edited the post to include the correct one.

@matthewp
Copy link
Contributor

matthewp commented Apr 9, 2024

Thanks

@matthewp matthewp added needs triage Issue needs to be triaged and removed needs repro Issue needs a reproduction labels Apr 9, 2024
@matthewp
Copy link
Contributor

matthewp commented May 3, 2024

@mef What am I missing? It appears to be working.

Area.mp4

@matthewp matthewp added needs response Issue needs response from OP and removed needs triage Issue needs to be triaged labels May 3, 2024
@mef
Copy link
Author

mef commented May 4, 2024

@matthewp you are correct, the provided code works as expected right now.

I am really confused, as when I wrote this reproduction scenario it showed the buggy behaviour. Apologies for the mix-up and the time wasted.

The problem is still present inside my production code, but I have not been able to isolate the minimal part displaying the issue.

I propose that we close this issue, I'll refactor my code some day to generate the html in a svelte component rather than inside a Javascript string + @html.

Thanks for your patience and support.

@martrapp
Copy link
Member

martrapp commented May 6, 2024

Closed as suggested by @mef in the previous comment

@martrapp martrapp closed this as completed May 6, 2024
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
Projects
None yet
Development

No branches or pull requests

3 participants