Skip to content

bug(material/tree): Keyboard toggling child node collapses parent in mat-tree with mat-nested-tree-node #33120

@heyitstay11

Description

@heyitstay11

Is this a regression?

  • Yes, this behavior used to work in the previous version

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:

  1. Create a mat-tree using mat-nested-tree-node.
  2. Expand a parent node so that child nodes are visible.
  3. Use keyboard navigation (Tab / Arrow keys) to focus a child node.
  4. Press Enter or Space to toggle the child node.
  5. 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.

Image

Environment

  • Angular: 21.1.0
  • CDK/Material: 21.1.0
  • Browser(s): Chrome, Firefox
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 11

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions