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

click only to specific element with dedicated prop

Open alessandronocera89 opened this issue 5 years ago • 2 comments

There is a way to allow the click on a specific element (in example: dir_root/some_children) in order to avoid not secure click? In addiction to above example, it's pretty good to allow the click only to the children and not on the dir_root. As showCheckbox prop I guess. In this way I can allow to click only to specific element.

alessandronocera89 avatar Apr 27 '20 15:04 alessandronocera89

I am afraid I do not fully understand the question. I am unsure what you mean by a "secure click."

If you pass the property checkModel="all", clicking a node only checks that node and does not affect the state of any children or parent nodes.

There is also the ability to hide the checkboxes on individual nodes. You can make only the leaf nodes checkable by passing in onlyLeafCheckboxes to the tree component, or for individual nodes you can use the showCheckbox option:

nodes = {
  'value': 'root',
  'label': 'Root Node',
  'showCheckbox': false,
  'children': [
    { 'value': 'child-1', 'label': 'Child 1' },
    { 'value': 'child-2', 'label': 'Child 2' },
  ],
};

jakezatecky avatar Apr 28 '20 22:04 jakezatecky

Your code is ok only if there is no onClick callback. My idea was to add a prop like showCheckbox in this way (default is true);

nodes = {
  'value': 'root',
  'label': 'Root Node',
'isClickable': false
  'showCheckbox': false,
  'children': [
    { 'value': 'child-1', 'label': 'Child 1' },
    { 'value': 'child-2', 'label': 'Child 2' },
  ],
};

In this way will be possible to not allow the click on specific element (and have a secure click only on the element that we want).

That it's and thank you Jake, this is my opinion.

alessandronocera89 avatar Apr 29 '20 07:04 alessandronocera89