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

Odd warnings when using Transition inside a "parent" element. #3385

Open
dev-inigmas opened this issue Dec 18, 2024 · 4 comments
Open

Odd warnings when using Transition inside a "parent" element. #3385

dev-inigmas opened this issue Dec 18, 2024 · 4 comments

Comments

@dev-inigmas
Copy link

dev-inigmas commented Dec 18, 2024

Describe the bug

Odd warnings are being generated when using Transition|Suspense inside of a "parent" element; such as: <ul> or <tbody>.

Example warning:

[WARNING] Non-fatal error at ... while calling insertNode on

<ul class="flex-auto mx-3 divide-y shadow-sm shadow-black divide-zinc-900/​20 dark:​divide-zinc-100/​20 bg-zinc-200 dark:​bg-zinc-900 sm:​rounded-xl overflow-y-auto overflow-x-hidden" role=​"list"><li class="flex items-center justify-between p-2 gap-x-6">​…​</li>
<li class="flex items-center justify-between p-2 gap-x-6">​…​</li><li class="flex items-center justify-between p-2 gap-x-6">​…​</li><li class="flex items-center justify-between p-2 gap-x-6">​…​</li><li class="flex items-center justify-between p-2 gap-x-6">​…​</li><li class="flex items-center justify-between p-2 gap-x-6">​…​</li><li class="flex items-center justify-between p-2 gap-x-6">​…​</li><li class="flex items-center justify-between p-2 gap-x-6">​…​</li><li class="flex items-center justify-between p-2 gap-x-6">​…​</li><li class="flex items-center justify-between p-2 gap-x-6">​…​</li><li class="flex items-center justify-between p-2 gap-x-6">​…​</li><li class="flex items-center justify-between p-2 gap-x-6">​…​</li><li class="flex items-center justify-between p-2 gap-x-6">​…​</li><!---->
</ul>
DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.

Code that produced the warnings:

view! {
  <NavigatorList title="Registered Flows">
    <Transition
      fallback=move || view! { <CardListItem>"Loading..."</CardListItem> }
    >
      <For
        each=move || {
          flows_rsrc.get()
            .and_then(Result::ok)
            .unwrap_or_default()
            .into_iter()
        }
        key=|flow| flow.id
        children=|flow| view! { <FlowItem flow /> }
      />
    </Transition>
  </NavigatorList>
}

Code that does not produce warnings:

view! {
  <Transition
    fallback=|| view! {
      <NavigatorList title="Registered Flows">
        <CardListItem>"Loading..."</CardListItem>
      </NavigatorList>
    }
  >
    <NavigatorList title="Registered Flows">
      <For
        each=move || {
          flows_rsrc.get()
            .and_then(Result::ok)
            .unwrap_or_default()
            .into_iter()
        }
        key=|flow| flow.id
        children=|flow| view! { <FlowItem flow /> }
      />
    </NavigatorList>
  </Transition>
}

Another example where warnings were fixed by putting the "parent" element inside of the Transition:

view! {
  <Transition
    fallback=|| view! {
      <tbody>
        <TableList>
          <td colspan="4">"Loading notificatons..."</td>
        </TableList>
      </tbody>
    }
  >{ move || {
    let notifs = memoize_res_list(notif_res, |s| s.id);
    view! {
      <tbody>
        <For
          each=move || notifs.get()
          key=|(id, _)| *id
          children=|(_, notif)| view! { <NotifItem notif /> }
        />
      </tbody>
    }
  }}</Transition>
}

Before, the component with this view! was being called from within a tbody.

Leptos Dependencies

Please copy and paste the Leptos dependencies and features from your Cargo.toml.

For example:

leptos        = { version="0.7.1", features=["nightly"] }
leptos_axum   = { version="0.7.1" }
leptos_meta   = { version="0.7.1" }
leptos_router = { version="0.7.1", features=["nightly"] }

To Reproduce

See reproduction: https://github.com/dev-inigmas/leptos_3385

Within an app with SSR+Hydration and Routing. Reload the app (F5), navigate to a route with the effected code such that it's client-side rendered. Not sure if a CSR-only app does this also.

<ParentElement> // tested ul and tbody so far
  <Transition>
    <For ...>
      <ChildElement /> // tested li and tr so far
    </For>
  </Transition>
</ParentElement>

Expected behavior

I didn't expect having the "parent" element outside of the Transition|Suspense to cause tons of warning to pop up in the console. Other than that - I haven't discovered any odd side-effects yet.

Screenshots
image

Additional context
Thanks.

If a minimal example project is needed, please let me know.

@gbj
Copy link
Collaborator

gbj commented Dec 18, 2024

Please include a minimal reproduction: i.e., a small, self-contained example that compiles as is, without requiring other code from your project, and reproduces the bug.

@gbj
Copy link
Collaborator

gbj commented Dec 18, 2024

Oh and just to clarify: Does the app work as expected (but emits warnings), or is there a bug in actual behavior (other than the warnings)?

@dev-inigmas
Copy link
Author

yeah - just a bunch of strange warnings filling up the console. I can work on a minimal example soon. Thanks.

@dev-inigmas
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants