Skip to content

Children props and event handlers are lost when rendered to DOM #27

@adrian2x

Description

@adrian2x

I have some code that defines a Tabs component like tab-list. I am using it like this:

<tab-list>
    <div data-key="mouse" title="Mouse">
      <DemoContent />
    </div>
    <div data-key="keyboard" title="Keyboard">Keyboard Settings</div>
    <div data-key="gamepad" title="Gamepad">Gamepad Settings</div>
</tab-list>

function DemoContent() {
  return (
    <div>
      <h2>Sample title</h2>
      <button onClick={() => alert()}>Submit</button>
    </div>
  )
}

This does not work because the children passed to the Tabs component is just an empty element without any props or children.

However, if I you the children inside a slot, they slot is a node with the correct children and props BUT the event listeners don't fire. So this renders the static content, but it is not interactive.

  1. Can we avoid using the slot and parse any children correctly?
  2. How can we get the event listeners for nested components to work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpreactRelates to preactement packagereactRelates to reactement package

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions