Skip to content

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

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

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

Conversation

@PaulGMardling

@PaulGMardling Paul Mardling (PaulGMardling) commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Previous Behavior

The Tree actions example only showed uncontrolled menus. Controlled state survives action-slot unmounting and can reopen a menu when actions reappear.

New Behavior

Add a focused Actions Controlled story demonstrating per-item state, reset on hidden actions, and persistent-row focus restoration without breaking trigger dismissal. Link it from Actions.

V9 stories/docs only; no runtime or API changes. The private stories package needs no Beachball file.

Reproduction and fix verification

In an isolated checkout of this PR branch, use Node 22 and the pinned Yarn. From the repository root, install dependencies with yarn install --immutable if needed, then run:

yarn nx run react-tree-stories:storybook --port=6103 --ci --no-open

Once ready, open http://localhost:6103/iframe.html?id=components-tree--actions-controlled&viewMode=story in a fresh Chromium page. This executes the checkout's source, not a deployed baseline.

Fixture: packages/react-components/react-tree/stories/src/Tree/TreeActionsControlled.stories.tsx.

  1. Hover item 1 and open its menu without first focusing the row.
  2. Hover item 2: item 1's menu/actions disappear and focus should return to item 1. Hover back: actions return with the menu closed.
  3. Reopen and click the same trigger: the menu closes. Reopen and press Escape or select Rename: focus returns to the trigger.
  4. Reload; Tab enters the tree, then Tab reaches its trigger. Enter opens; Escape returns focus. Clicking another row/control must preserve that destination.

Validation and limits

Local checks on 20 November 2026:

  • 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: 40 tests, 1 snapshot (matching Nx cache; not story-interaction coverage).
  • git diff --check — passed.
  • Storybook command above — served successfully. Playwright Chromium passed the interactions above; Chromium/WebKit also passed repeated trigger toggles and touch-emulated dismissal.

These browser checks preceded subsequent base merges; they are not fresh behavioral validation of the merged head. The earlier local yarn nx run react-tree-stories:type-check failed in unchanged react-table dependencies and has not subsequently passed locally; passing CI is separate evidence.

WebKit still loses focus to BODY on hover dismissal in both this and the unchanged Actions story; its cause remains unisolated. Firefox, physical-device and screen-reader validation are incomplete. This documentation change does not claim to fix that browser limitation or establish accessibility conformance.

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

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@PaulGMardling
Paul Mardling (PaulGMardling) marked this pull request as ready for review November 20, 2026 13:55

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