react-tree-list icon indicating copy to clipboard operation
react-tree-list copied to clipboard

Implement "allowDropInside" on the data object

Open bartaxyz opened this issue 5 years ago • 0 comments

Defines whether content can be dropped inside an item. Children are still allowed, it's just impossible to drop any more children inside.

import React, { useState } from "react";
import { ReactTreeList, ReactTreeListProps } from '@bartaxyz/react-tree-list';

const Component: React.FC = () => {
  const [data, setData] = useState<ReactTreeListProps["data"]>([
    {
      label: "none",

      // This parameter will keep current children but prevent other items to be dropped inside
      allowDropInside: true,

      // Nodes inside "children" will be displayed and it will be possible to sort them, or drag them out
      children: [
        { label: "Heyo", },
      ],
    },
  ]);

  return (
    <ReactTreeList
      data={data}
      onChange={setData}
    />
  );
};

Default: true

bartaxyz avatar Aug 22 '20 20:08 bartaxyz