Skip to content

checked: true boolean inversion issue #38

@ForbiddenEra

Description

@ForbiddenEra

Hi,

If your tree array is as such:

let data = [
  {
    "id": "0",
    "text": "0",
    "checked": true,
    "children": [
      {
        "id": "0-0",
        "text": "0-0",
	"checked": true,
        "children": []
      }
    ]
  }
]

Then no nodes are selected. This is because the checked must be implemented as a toggle of sorts, inverting the previous value, so because the parent is checked, setting checked: true on a child causes the parent to be inverted, unchecking it and seemingly also unchecking the child.

This doesn't make intuitive sense and it took me a good few minutes to figure out what was going on in this case.

Because of this, you either need to set checked: true on the most-parent node that you want all children checked in, or, if you don't want all that parent's children checked, then you need to not have the property on the parent and only on the child nodes you want checked.

checked: true should mean I want that entry checked, regardless of any previous values; there should be no inversion toggling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions