yew-hooks icon indicating copy to clipboard operation
yew-hooks copied to clipboard

Bug in use_drop with nested target

Open ctron opened this issue 2 years ago • 0 comments

I need to create a reproducer, but I think there is a bug in the use_drop when the ref is placed in a nested context:


#[function_component(Other)]
fn other(props: &ChildrenProps) -> Html {
  html!(<div> { for props.children.iter() } </div>)
}

#[function_component(Example)]
fn example() -> Html {
  let node = use_node_ref();
  let drop = use_drop(node.clone());

  html!(
    <div ref={node}> // works when it's here
      <Other>
        <div ref={node}> // but not when it's here
        </div>
      </Other>
    </div>
  )
}

Through the browser's DOM inspector, I can see the events being attached when putting the ref on the other one, but not when it's in the inner one.

ctron avatar Jul 28 '23 14:07 ctron