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

Add flexible tagName support to PanelProps #414

Merged
merged 1 commit into from
Sep 28, 2024
Merged

Conversation

in-ch
Copy link
Contributor

@in-ch in-ch commented Sep 27, 2024

related to (#407)

Instead of fixing the tagName type to keyof HTMLElementTagNameMap, it has been made flexible by using a generic type.
This allows TypeScript to better infer event object types like handleDrop when a specific tagName is provided in the component.

<Panel
    onDrop={(e: DragEvent<HTMLDivElement>) => {
      if (e.currentTarget.contains(e.relatedTarget)) return;
    }}
    className={styles.PanelRow}
    defaultSize={20}
    minSize={10}
    tagName="div"
  >
    <div className={styles.Centered}>left</div>
</Panel>

Copy link

vercel bot commented Sep 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-resizable-panels ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 0:19am

@bvaughn
Copy link
Owner

bvaughn commented Sep 28, 2024

I like this approach!

@bvaughn bvaughn merged commit 909f014 into bvaughn:main Sep 28, 2024
5 of 6 checks passed
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

Successfully merging this pull request may close these issues.

2 participants