microsoft / fluentui

Fluent UI web represents a collection of utilities, React components, and web components for building web applications.
https://react.fluentui.dev
Other
18.43k stars 2.72k forks source link

[Bug]: Expand/collapse is broken if there are more than one sub-trees on the second level of a Tree component #32929

Closed vimeng closed 2 weeks ago

vimeng commented 3 weeks ago

Component

Tree

Package version

9.54.17

React version

18

Environment

package.json:
{
  "name": "vite-react-typescript-starter",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^18",
    "@fluentui/react-components": "^9.54.17",
    "react-dom": "^18"
  },
  "devDependencies": {
    "@types/react": "^17",
    "@types/react-dom": "^17",
    "typescript": "~4.7.0",
    "@vitejs/plugin-react": "^4.2.0",
    "vite": "^5.0.0"
  }
}
browser: chrome and edge

Current Behavior

If a tree has more than one sub-trees in the second level, then clicking on the expand/collapse button on any sub-tree besides the last one will expand/collapse the root tree (first level) instead.

Expected Behavior

The expand/collapse button on the sub-trees should expand/collapse the corresponding sub-tree, not the root tree.

Reproduction

https://stackblitz.com/edit/udx4fe?file=src%2Fexample.tsx,package.json

Steps to reproduce

  1. Expand "level 1, item 1"
  2. Click on the expand button for "level 2, item 1"
  3. Observe that instead of expanding "level 2, item 1", "level 1, item 1" is collapsed
  4. The same behavior can be observed when clicking on the expand button for "level 2, item 2" as well

Are you reporting an Accessibility issue?

no

Suggested severity

Urgent - No workaround and Products/sites are affected

Products/sites affected

No response

Are you willing to submit a PR to fix?

no

Validations

dmytrokirpa commented 3 weeks ago

Hello @vimeng, I please check this example https://stackblitz.com/edit/udx4fe-kgiah2?file=src%2Fexample.tsx as it effectively addresses your scenario.

Demo:

https://github.com/user-attachments/assets/9ea05e1d-849e-419e-8610-b1e119e6f2b8

microsoft-github-policy-service[bot] commented 2 weeks ago

This issue has been marked as being beyond the support scope of Fluent UI's issues board. It will now be closed automatically for house-keeping purposes.

dmytrokirpa commented 2 weeks ago

@vimeng, should the solution provided not resolve your issue, you are welcome to reopen it. Thank you!