Skip to content

Implement "allowChildren" parameter on data #2

@bartaxyz

Description

@bartaxyz

This parameter defines whether children can or cannot be passed into the item. If false, this element also removes all current children. If you want to disallow only additional children but keep the current (keep them visible), use allowDropInside: false instead.

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 hide all children (not remove them from the object though)
      allowChildren: true,

      // Nodes inside "children" won't be displayed
      children: [
        { label: "Heyo", },
      ],
    },
  ]);

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

Default: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions