Is this a regression?
The previous version in which this bug was not present was
No response
Description
When using mat-tree with mat-nested-tree-node, toggling a child node via keyboard (Enter or Space) unexpectedly collapses the parent node.
This issue is reproducible using the official Angular Material documentation example "Tree with nested nodes (childrenAccessor)".
Reproduction
StackBlitz link: https://stackblitz.com/edit/9v65gmui?file=src%2Fexample%2Ftree-nested-child-accessor-overview-example.ts
Steps to reproduce:
- Create a mat-tree using mat-nested-tree-node.
- Expand a parent node so that child nodes are visible.
- Use keyboard navigation (Tab / Arrow keys) to focus a child node.
- Press Enter or Space to toggle the child node.
- Observe that the parent node collapses.
Expected Behavior
Pressing Enter/Space on a focused child node should toggle only the selected child node.
The parent node should remain expanded and unaffected.
Actual Behavior
Toggling a child node using the keyboard causes the parent node to collapse.
Environment
- Angular: 21.1.0
- CDK/Material: 21.1.0
- Browser(s): Chrome, Firefox
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 11
Is this a regression?
The previous version in which this bug was not present was
No response
Description
When using
mat-treewithmat-nested-tree-node, toggling a child node via keyboard (Enter or Space) unexpectedly collapses the parent node.This issue is reproducible using the official Angular Material documentation example "Tree with nested nodes (childrenAccessor)".
Reproduction
StackBlitz link: https://stackblitz.com/edit/9v65gmui?file=src%2Fexample%2Ftree-nested-child-accessor-overview-example.ts
Steps to reproduce:
Expected Behavior
Pressing Enter/Space on a focused child node should toggle only the selected child node.
The parent node should remain expanded and unaffected.
Actual Behavior
Toggling a child node using the keyboard causes the parent node to collapse.
Environment