Skip to content

[bug] Migrating from 1.5.1 to 1.6.0 resulting in some weirdness #185

Open
@thehig

Description

@thehig

I'm having some difficulty in migrating from 1.5.1 to 1.6.0.

I have resolved two separate issues that I will outline for anyone else that might get caught out by breaking changes in this PR.

Number 1: #13

This issue adds support for 'checkModel' with modes 'all' or 'leaf'.

  • The old way was 'leaf'.
  • The new default is 'all'.
  • Adding checkModel="leaf" to the component resolves this

Number 2: #171

This issue adds support for empty folders.

  • The old way if a node had empty children, it would behave as though it were a leaf.
  • The new way, if a node has empty children, it behaves as though it is an empty folder.
  • Modifying the datastructure for the checkbox tree to 'null out' the children when we are adding a leaf
node = {
  value: node_name,
  label: name,
  children: isLeaf ? null : [] // If this is a leaf, it should not have a children array
};

But now I'm getting some weirdness, and this is where the 'bug report' aspect of things begins:

  • I have a CheckboxTree that contains a list of nested folders.
  • Some folders in the CheckboxTree are empty (empty children array)
  • The CheckboxTree has checkModel="leaf" set

As a result of this, when I have an empty folder nested somewhere in my structure and I initialize the component with an empty checked array, these empty folders are becoming checked somehow.

I will repeat for clarity. My checked array is empty, but the "empty-children" "non-leaf" nodes are defaulting to checked.

Screenshots

Default state, just after loading. checked array is empty
image

Same state as above, just "drilled down" to the offending elements
image

For clarity (since I have to remove the labels) the first and third nodes are expanded showing no children inside them. The second node also has no children, but is not expanded. The fourth node has children and is expanded. This is all with an empty checked array and checkModel="leaf"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions