Skip to content

fix(react-headless-components-preview): provide MenuSplitGroup's context - #36669

Open
Ray Knight (ArrayKnight) wants to merge 2 commits into
microsoft:masterfrom
ArrayKnight:fix/headless-menu-split-group-context-36651
Open

fix(react-headless-components-preview): provide MenuSplitGroup's context#36669
Ray Knight (ArrayKnight) wants to merge 2 commits into
microsoft:masterfrom
ArrayKnight:fix/headless-menu-split-group-context-36651

Conversation

@ArrayKnight

@ArrayKnight Ray Knight (ArrayKnight) commented Aug 31, 2026

Copy link
Copy Markdown

The headless MenuSplitGroup calls renderMenuSplitGroup(state) with no contexts argument. useIsInMenuSplitGroup compares the context value it receives against the module-level default by identity, so with nothing provided the comparison is always false and no descendant can tell it is inside a split group. The user-visible consequence is that the gutter suppression a split group is supposed to apply — the icon and checkmark columns the trigger half drops in the Griffel-styled equivalent — never fires, because it is gated on exactly this hook.

The fix provides the contexts argument, memoized on state.setMultiline so the identity is stable across renders (an inline object literal would defeat the comparison in the other direction, re-firing every render). setMultiline itself stays the documented no-op — this changes what descendants can observe, not what the group does.

Fixes #36651.

Extracted from #36656 per maintainer request — each in-tree fix from that PR as an isolated change.

renderMenuSplitGroup falls back to menuSplitGroupContextDefaultValue when no
contexts argument is supplied, and MenuSplitGroup supplies none.
useIsInMenuSplitGroup compares against that default by identity, so it
returns false for every descendant of a headless MenuSplitGroup.

The visible effect is in useMenuItemBase's useIconAndCheckmarkAlignment: a
submenu trigger inside a split group is supposed to drop its icon and
checkmark gutters, and instead keeps them, widening one half of the group
by the gutter plus the row gap whenever the surrounding MenuList sets
hasIcons or hasCheckmarks.

Pass the state's own context value so the identity differs from the
default. The setMultiline it carries stays a no-op: the multiline
attribute remains a styling concern for consumers, as documented on the
hook.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wmpBCYJpDJCLXcScCWz1i
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Aj9uA3rCVgosnh2zNn8qkc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant