Skip to content

docs(react-tree): document controlled action menus - #37190

Draft
Paul Mardling (PaulGMardling) wants to merge 2 commits into
microsoft:masterfrom
PaulGMardling:docs/controlled-treeitem-menu
Draft

Paul Mardling (PaulGMardling) wants to merge 2 commits into
microsoft:masterfrom
PaulGMardling:docs/controlled-treeitem-menu

Conversation

@PaulGMardling

Copy link
Copy Markdown
Contributor

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 open when actions.onVisibilityChange reports visible: 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 40 TS2686 errors in 12 unchanged react-table render 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)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 12:35
@github-actions

Copy link
Copy Markdown

📊 Bundle size report

✅ No changes found

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation for controlled menu in tree item actions

2 participants