(n, val)
| 87 | |
| 88 | // Update the clicked node and all its descendants with the new checked value |
| 89 | const updateDescendants = (n, val) => { |
| 90 | newState[n.id] = val; |
| 91 | n.children?.forEach(child => { updateDescendants(child, val); }); |
| 92 | }; |
| 93 | updateDescendants(node, isChecked); |
| 94 | |
| 95 | // Update ancestor nodes to reflect the correct state (checked/unchecked/indeterminate) |