Skip to content

Commit 630a7e9

Browse files
author
Moaead Yahya
committed
Fix children error
1 parent 3619076 commit 630a7e9

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

lib/index.browser.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/CheckboxTree.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class CheckboxTree extends React.Component {
202202
determineShallowCheckState(node, noCascade) {
203203
const flatNode = this.state.model.getNode(node.value);
204204

205-
if (flatNode.isLeaf || noCascade) {
205+
if ((flatNode && flatNode.isLeaf) || noCascade) {
206206
return flatNode.checked ? 1 : 0;
207207
}
208208

@@ -252,7 +252,7 @@ class CheckboxTree extends React.Component {
252252
flatNode.checkState = this.determineShallowCheckState(node, noCascade);
253253
flatNode.cascadeCheckState = this.determineShallowCheckState(node, false);
254254
// Show checkbox only if this is a leaf node or showCheckbox is true
255-
const showCheckbox = onlyLeafCheckboxes ? flatNode.isLeaf : flatNode.showCheckbox;
255+
const showCheckbox = onlyLeafCheckboxes ? (flatNode && flatNode.isLeaf) : flatNode.showCheckbox;
256256

257257
// Render only if parent is expanded or if there is no root parent
258258
const parentExpanded = parent.value ? model.getNode(parent.value).expanded : true;
@@ -278,7 +278,7 @@ class CheckboxTree extends React.Component {
278278
lang={lang}
279279
optimisticToggle={optimisticToggle}
280280
isHtml={node.isHtml}
281-
isLeaf={flatNode.isLeaf}
281+
isLeaf={flatNode && flatNode.isLeaf}
282282
isParent={flatNode.isParent}
283283
showCheckbox={showCheckbox}
284284
showNodeIcon={showNodeIcon}

src/js/NodeModel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class NodeModel {
112112
toggleChecked(node, isChecked, noCascade, toggleParent = false) {
113113
const flatNode = this.flatNodes[node.value];
114114

115-
if (flatNode.isLeaf || noCascade) {
115+
if ((flatNode && flatNode.isLeaf) || noCascade) {
116116
if (node.disabled) {
117117
return this;
118118
}
@@ -121,7 +121,7 @@ class NodeModel {
121121
this.toggleNode(node.value, 'checked', isChecked);
122122
} else {
123123
// Percolate check status down to all children
124-
flatNode.children.forEach((child) => {
124+
flatNode && flatNode.children.forEach((child) => {
125125
this.toggleChecked(child, isChecked, noCascade, toggleParent);
126126
});
127127
if(toggleParent){

0 commit comments

Comments
 (0)