Repository navigation
docs(react-tree): document controlled action menus - #37190
Draft
Paul Mardling (PaulGMardling) wants to merge 2 commits into
Draft
Paul Mardling (PaulGMardling) wants to merge 2 commits into
Paul Mardling (PaulGMardling) wants to merge 2 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
📊 Bundle size report✅ No changes found |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Pointer navigation can unmount the focused menu and its trigger without restoring focus to the persistent TreeItem, leaving focus on the document body and disrupting keyboard navigation.
1 open issue
What changed in this PR
Documents controlled menus in Fluent UI v9 Tree actions, addressing #32485 by showing how to prevent stale menu state when hidden actions remount. No runtime or public API changes are included.
Changes:
- Adds an Actions Controlled story with per-item state and visibility-based reset.
- Explains action unmounting and links the example from the existing Actions documentation.
- Registers the new story in the Tree story index.
| File | Description |
|---|---|
packages/react-components/react-tree/stories/src/Tree/TreeActionsControlled.stories.tsx |
Adds the controlled-menu example and usage guidance. |
packages/react-components/react-tree/stories/src/Tree/TreeActions.stories.tsx |
Documents the reset requirement and links the new example. |
packages/react-components/react-tree/stories/src/Tree/index.stories.tsx |
Exports the Actions Controlled story. |
Review effort: Balanced
Comment on lines
+13
to
+20
| } from '@fluentui/react-components'; | ||
| import { MoreHorizontal20Regular } from '@fluentui/react-icons'; | ||
|
|
||
| const ItemWithControlledMenu = ({ children }: { children: string }): JSXElement => { | ||
| const [open, setOpen] = React.useState(false); | ||
|
|
||
| return ( | ||
| <TreeItem itemType="leaf" aria-description="has actions"> |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Previous Behavior
The Tree actions example only demonstrated an uncontrolled menu. A controlled menu can reopen when hidden actions reappear because unmounting the menu does not reset state held by its parent.
New Behavior
Add an Actions Controlled story showing per-item menu state and resetting
openwhenactions.onVisibilityChangereportsvisible: false. Explain the unmounting behavior and link the example from the existing Actions documentation.V9 documentation only; no runtime or public API changes. No Beachball file is needed for the private stories package.
Validation
yarn nx run react-tree-stories:format --configuration=check— passed.yarn nx run react-tree-stories:lint— passed.yarn nx run react-tree:test --runInBand --testPathPatterns=TreeItemLayout— passed: 3 suites, 40 tests, 1 snapshot.git diff --check— passed.yarn nx run react-tree-stories:storybook --port=6103 --ci --no-open— served the new story successfully. DOM/synthetic-event checks reproduced stale reopening with the reset temporarily omitted and confirmed both items return with closed menus after restoring it. Portalled menu focus and Escape were also checked.yarn nx run react-tree-stories:type-check— blocked by 40TS2686errors in 12 unchangedreact-tablerender files during its dependency build.yarn nx run react-tree-stories:type-check --excludeTaskDependencies— failed on unresolved package declarations after the dependency build failure; not a passing type check.Native end-to-end pointer/keyboard navigation and screen-reader testing were not run.
Related Issue(s)