Checkbox tree don't work properly (official documentation example) => https://material.angular.io/components/tree/examples
Se attached images, after click on parent childs are not selected
1)

2)

3)

see my images and offical examples:
https://material.angular.io/components/tree/examples
or:
https://stackblitz.com/angular/gabkadkvybq?file=app%2Ftree-checklist-example.ts
Thanks and Regards
I actually just had this brought to my attention by my team's QA. I have not yet been able to figure out how to get around this. My process to reproduce this bug is exactly the same as listed above.
Actually the problem is not the children selection, but the root internal handling:

As you can see in the above image, the properties indetermined and checked are set as false both on the root left on the initial situation (Reminders) and on the root on which I followed the steps on the initial post (Groceries).
The first root is both not-indefined and not-checked, but is displayed as checked,
I ran into the same issue a couple of days ago, I managed to find a solution.
On the checkboxes I suggest to bind the handler to the "click" event instead of the "change" .
First in the handler do event.preventDefault() so the internal state of the checkboxes won't change and it won't affect the visual state of the checkbox.
The handlers:
More over, consider adding the mappers of simpleNode and flatNode inside the dataSource. It will save time and space instead of declaring those every time.
Found a solution:
in the component you have to define another method, say descendantsAllUnselected(node), similar to the existing descendantsAllSelected(node).
descendantsAllUnselected(node: TodoItemFlatNode): boolean {
const descendants = this.treeControl.getDescendants(node);
return descendants.every(child => !this.checklistSelection.isSelected(child));
}
In the HTML, change the [checked] property of the root checkbox to
[checked]="descendantsAllSelected(node) || !descendantsAllUnselected(node)".
Why? I don't know. But it works.
Probably there's a bug in the isSelected method of the SelectionModel class.
@bellons91, with your solution if you:
@Nastia1409 This solved the issue for me. Thanks!
@ducalai damn, you are right! Thanks
I have found a solution, I will be creating a pull request shortly. It also solves your problem @ducalai
@fabioloreggian thanks for your solution! Almost done...
=> All children stay checked
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._