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

Panic when adding a node #249

Closed
simonchatts opened this issue Sep 17, 2021 · 0 comments · Fixed by #251
Closed

Panic when adding a node #249

simonchatts opened this issue Sep 17, 2021 · 0 comments · Fixed by #251
Labels
C-bug Category: bug, something isn't working

Comments

@simonchatts
Copy link

Describe the bug
Sometimes, when a dom node is dynamically added to an existing tree, one can hit the panic in utils::render::reconcile_fragments.

To Reproduce
Render the component below, using release 0.6.0:

use sycamore::prelude::*;

#[component(ReproBug<G>)]
pub fn repro_bug() -> Template<G> {
    let mid_drag = Signal::new(false);

    let on_drag_enter = cloned!((mid_drag) => move |_|
        mid_drag.set(true)
    );

    template! {
        div(style="background:red; color:white;margin: 10px; width: 120px;",
            draggable="true") { "↓ Drag me! ↓"}

        div(style="background:blue; color:white; margin: 10px; width: 120px;",
            on:dragenter=on_drag_enter) { "→ Onto here! ←"}

        (if *mid_drag.get() {
            template! { p() { "Dragging!" } }
        } else {
            template! {}
        })
    }
}

If I drag the red div onto the blue one. I get the panic:

panicked at 'node 2 in existing nodes Vec is not a child of parent. node = DomNode(
    "<p>Dragging!</p>",
)', ~/.cargo/registry/src/github.com-1ecc6299db9ec823/sycamore-0.6.0/src/utils/render.rs:240:17

Expected behavior
No panic, and the "Dragging!" p node should be added to the dom tree.

Environment

  • Sycamore: 0.6.0
  • Browser: tested on Chrome, Firefox, and Safari
  • OS: MacOS
@simonchatts simonchatts added the C-bug Category: bug, something isn't working label Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug, something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant