#Framework Component not showing with View Transitions

1 messages · Page 1 of 1 (latest)

hollow goblet
#

I have a page in my astro project. When I open this page from another one (which contains Sidebar but not PatientSidebar), Sidebar shows as expected, but PatientSidebar does not display unless refreshed.

---
import "@/astro/src/styles/main.css";

import { ViewTransitions } from "astro:transitions";

import Sidebar from "@components/react/Sidebar";
import PatientSidebar from "@components/react/PatientSidebar";
---

<html>
  <head>
    <title>Test</title>

    <ViewTransitions />
  </head>

  <body class="flex flex-row items-center justify-center align-middle h-screen">
    <Sidebar client:only transition:persist />
    <PatientSidebar client:only transition:persist />

    <main class="w-full h-full flex flex-col">
      <slot />
    </main>
  </body>
</html>

I have also noticed that when I remove the <ViewTransitions /> tag, PatientSidebar appears as expected. Is there a reason for this behaviour?

candid blazeBOT
#

Hi @hollow goblet. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the extracts, it seems like you're experiencing an issue with Astro's View Transitions feature. This feature is designed to provide smooth transitions between pages in your Astro application. However, there have been reported issues with View Transitions causing components to not render or styles to disappear, especially when used with certain JavaScript frameworks like React, Vue, and Svelte (source (https://github.com/withastro/astro/issues/8361), source (https://github.com/withastro/astro/issues/8856), source (https://github.com/withastro/astro/issues/8944)).

In your case, it seems like the PatientSidebar component is not rendering when navigating from a page that does not contain it. This could be due to a similar issue as reported in the extracts.

One possible workaround suggested in a Discord support thread (https://discord.com/channels/830184174198718474/1148022240080826388) is to ensure that any scripts associated with your components are designed to work with View Transitions. This is because when you use <ViewTransitions/>, a full page load only happens once at the beginning. Later on, the content of the page is replaced with new content as you navigate, but there are no full page loads. This can affect how scripts are executed.

If the issue persists, it might be worth reporting this as a bug to the Astro team on their GitHub issues page (https://github.com/withastro/astro/issues). Be sure to provide a minimal reproducible example to help them diagnose the issue.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: