Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(CdkTree): Clicking on nested tree nodes collapses parent tree node #29830

Closed
1 task done
cfinlinson-incomm opened this issue Oct 4, 2024 · 2 comments · Fixed by #29875
Closed
1 task done

bug(CdkTree): Clicking on nested tree nodes collapses parent tree node #29830

cfinlinson-incomm opened this issue Oct 4, 2024 · 2 comments · Fixed by #29875
Assignees
Labels
area: material/tree docs This issue is related to documentation P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@cfinlinson-incomm
Copy link

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

Angular CDK 17

Description

When using cdk-nested-tree-node, if I click on a child/leaf node, it collapses the parent tree node.

This does not occur when using cdk-tree-node; presumably, DOM click events are bubbling up and unexpectedly being handled by parent nodes. This was not happening on Angular CDK 17.

Reproduction

StackBlitz link: Angular components docs: https://material.angular.io/cdk/tree/examples#cdk-tree-nested-level-accessor
Steps to reproduce:

  1. Click on a parent node (e.g. "Fruit")
  2. Click on a nested child node (e.g. "Apple")

Expected Behavior

I would expect the nodes to be expanded or collapsed only when I click an element with the cdkTreeNodeToggle directive. But it seems to expand/collapse whenever I click anywhere in the sub-DOM of the cdk-nested-tree-node, including child nodes.

Actual Behavior

Clicking on child nodes collapses the parent node. Also, clicking on a part of the node that is not the cdkTreeNodeToggle collapses the node.

Environment

  • Angular: 17
  • CDK/Material: 17
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS
@cfinlinson-incomm cfinlinson-incomm added the needs triage This issue needs to be triaged by the team label Oct 4, 2024
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: material/tree and removed needs triage This issue needs to be triaged by the team labels Oct 9, 2024
@crisbeto crisbeto self-assigned this Oct 14, 2024
@crisbeto crisbeto added the docs This issue is related to documentation label Oct 14, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Oct 14, 2024
Fixes the following issues with the tree live examples:
* Both the tree node and the toggle were marked as toggles which meant that clicking anywhere would close the tree.
* The toggles weren't centered relative to the text.
* A couple of examples had the same name and one had weird punctuation.

Fixes angular#29830.
crisbeto added a commit to crisbeto/material2 that referenced this issue Oct 14, 2024
Fixes the following issues with the tree live examples:
* Both the tree node and the toggle were marked as toggles which meant that clicking anywhere would close the tree.
* The toggles weren't centered relative to the text.
* A couple of examples had the same name and one had weird punctuation.

Fixes angular#29830.
@crisbeto
Copy link
Member

Looks like this was a docs issue. You can see how I've fixed it in #29875, if you want to fix it in your app.

crisbeto added a commit that referenced this issue Oct 14, 2024
Fixes the following issues with the tree live examples:
* Both the tree node and the toggle were marked as toggles which meant that clicking anywhere would close the tree.
* The toggles weren't centered relative to the text.
* A couple of examples had the same name and one had weird punctuation.

Fixes #29830.

(cherry picked from commit 52cad9c)
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/tree docs This issue is related to documentation P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants