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

Drag and Drop should be handled within the level hierarchy #242

Open
GVSSri opened this issue Apr 10, 2024 · 0 comments
Open

Drag and Drop should be handled within the level hierarchy #242

GVSSri opened this issue Apr 10, 2024 · 0 comments

Comments

@GVSSri
Copy link

GVSSri commented Apr 10, 2024

import { Tree } from "react-arborist";
import { data } from "./data";

function Node({ node, style, dragHandle }) {
/* This node instance can do many things. See the API reference. */
return (
<div style={style} ref={dragHandle} onClick={() => node.toggle()}>
{node.isLeaf ? "🍁" : "🗀"} {node.data.name}

);
}

/* Customize Appearance /
export default function App() {
return (
<Tree
initialData={data}
openByDefault={false}
width={600}
height={1000}
indent={24}
rowHeight={36}
paddingTop={30}
paddingBottom={10}
padding={25 /
sets both */}
>
{Node}

);
}

export const data = [
{ id: "1", name: "Unread" },
{ id: "2", name: "Threads" },
{
id: "3",
name: "Chat Rooms",
children: [
{ id: "c1", name: "General" },
{ id: "c2", name: "Random" },
{ id: "c3", name: "Open Source Projects" }
]
},
{
id: "4",
name: "Direct Messages",
children: [
{ id: "d1", name: "Alice" },
{ id: "d2", name: "Bob" },
{ id: "d3", name: "Charlie" }
]
}
];

Example: Chat Rooms and Direct Messages are parent I need drag within the level same for child also. Appreciate your help. Thanks

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

1 participant