)
diff --git a/src/tree-manager/flatten-tree.js b/src/tree-manager/flatten-tree.js
index b5c563d0..f579ada8 100644
--- a/src/tree-manager/flatten-tree.js
+++ b/src/tree-manager/flatten-tree.js
@@ -1,4 +1,5 @@
import getPartialState from './getPartialState'
+import Node from './node'
import { isEmpty } from '../utils'
@@ -216,16 +217,8 @@ function walkNodes({
_rv = { list: new Map(), defaultValues: [], singleSelectedNode: null },
}) {
const single = simple || radio
- nodes.forEach((node, i) => {
- node._depth = depth
-
- if (parent) {
- node._id = node.id || `${parent._id}-${i}`
- node._parent = parent._id
- parent._children.push(node._id)
- } else {
- node._id = node.id || `${rootPrefixId ? `${rootPrefixId}-${i}` : i}`
- }
+ nodes.forEach((n, i) => {
+ const node = new Node({ rootPrefixId, depth, parent, index: i, ...n })
if (single && node.checked) {
if (_rv.singleSelectedNode) {
@@ -261,6 +254,7 @@ function walkNodes({
radio,
showPartialState,
hierarchical,
+ rootPrefixId,
_rv,
})
diff --git a/src/tree-manager/keyboardNavigation.js b/src/tree-manager/keyboardNavigation.js
index 0509a06d..e265490d 100644
--- a/src/tree-manager/keyboardNavigation.js
+++ b/src/tree-manager/keyboardNavigation.js
@@ -151,8 +151,7 @@ const getNextFocusAfterTagDelete = (deletedId, prevTags, tags, fallback) => {
if (index < 0 || !tags.length) return fallback
index = tags.length > index ? index : tags.length - 1
- const newFocusId = tags[index]._id
- const focusNode = document.getElementById(getTagId(newFocusId))
+ const focusNode = document.getElementById(tags[index].getDOMId('tag'))
if (focusNode) {
return focusNode.firstElementChild || fallback
}
diff --git a/src/tree-manager/node.js b/src/tree-manager/node.js
new file mode 100644
index 00000000..826ab8c5
--- /dev/null
+++ b/src/tree-manager/node.js
@@ -0,0 +1,48 @@
+/**
+ * Represents a tree node (not DOM node) in the data tree.
+ * It can have the following properties:
+ *
+ * id {string|optional} User defined id, comes from `data` passed to the component.
+ * _id {string} Internal id, auto generated if `id` is not defined, otherwise set to `id`.
+ * rootPrefixId {string} The id of the component's instance.
+ * parent {Node} Parent node, if a child.
+ * label {string|required} Checkbox label
+ * value {string|required} Checkbox value
+ * children {array|optional} Array of child nodes
+ * checked {bool|optional} Initial state of checkbox. if true, checkbox is selected and corresponding pill is rendered.
+ * disabled {bool|optional} Selectable state of checkbox. if true, the checkbox is disabled and the node is not selectable.
+ * expanded {bool|optional} If true, the node is expanded (children of children nodes are not expanded by default unless children nodes also have expanded: true).
+ * className {string|optional} Additional css class for the node. This is helpful to style the nodes your way
+ * tagClassName {string|optional} Css class for the corresponding tag. Use this to add custom style the pill corresponding to the node.
+ * actions {array