feat(react-button): expose useSplitButtonBase_unstable base hook - #36524
Open
Victor Genaev (mainframev) wants to merge 1 commit into
Open
feat(react-button): expose useSplitButtonBase_unstable base hook#36524Victor Genaev (mainframev) wants to merge 1 commit into
Victor Genaev (mainframev) wants to merge 1 commit into
Conversation
|
Pull request demo site: URL |
Victor Genaev (mainframev)
force-pushed
the
feat/split-button-base-hook
branch
from
August 5, 2026 20:13
60cc5a7 to
afd18dd
Compare
Victor Genaev (mainframev)
force-pushed
the
feat/split-button-base-hook
branch
from
August 5, 2026 20:19
afd18dd to
60b51b8
Compare
Victor Genaev (mainframev)
force-pushed
the
feat/split-button-base-hook
branch
3 times, most recently
from
August 5, 2026 21:43
752def6 to
7b50ac1
Compare
…c base hook Splits SplitButton's internal logic into two layers: - useSplitButtonBase_unstable: design-agnostic base hook (no appearance/shape/ size), producing ARIA-wired root/menuButton/primaryActionButton slots with placeholder 'button' element metadata. - useSplitButton_unstable: styled wrapper that composes the base hook and recreates both child slots via slot.optional with the concrete Button/ MenuButton element types and styling defaults. Also widens renderSplitButton_unstable to accept SplitButtonBaseState so it can be reused directly by headless consumers instead of being duplicated. Adds SplitButtonBaseProps/SplitButtonBaseSlots/SplitButtonBaseState, exported from the SplitButton and package root barrels, together with a bundle-size fixture. This unblocks a future headless SplitButton built directly on the base hook.
Victor Genaev (mainframev)
force-pushed
the
feat/split-button-base-hook
branch
from
August 5, 2026 21:48
7b50ac1 to
9586fca
Compare
Victor Genaev (mainframev)
marked this pull request as ready for review
August 5, 2026 21:54
Tudor Popa (tudorpopams)
requested review from
Martin Hochel (Hotell),
PaulGMardling and
Dmytro Kirpa (dmytrokirpa)
and removed request for
Martin Hochel (Hotell)
August 6, 2026 12:07
|
|
||
| console.log(useSplitButtonBase_unstable); | ||
|
|
||
| export default { |
Contributor
There was a problem hiding this comment.
is this dev-only thing or do you want to keep this?
| * structure and ARIA attributes, without design-specific props such as `appearance`, `shape`, or | ||
| * `size`. | ||
| * | ||
| * The `menuButton` and `primaryActionButton` slots returned by this hook use placeholder element |
Contributor
There was a problem hiding this comment.
could we shorten the comment a bit?
| const { appearance = 'secondary', shape = 'rounded', size = 'medium', ...rest } = props; | ||
| const baseState = useSplitButtonBase_unstable(rest, ref as React.Ref<HTMLDivElement>); | ||
|
|
||
| const menuButtonShorthand = slot.optional<ExtractSlotProps<NonNullable<SplitButtonSlots['menuButton']>>>( |
Contributor
There was a problem hiding this comment.
We should use slot from props and pass slot from base state to default props, something like:
const menuButtonShorthand = slot.optional(props.menuButton, {
{
defaultProps: {
...baseState.menuButton,
appearance,
shape,
size,
},
renderByDefault: true,
elementType: MenuButton,
},
})In that case no type-casting is needed, and everything should work as expected
| }, | ||
| ); | ||
| const primaryActionButtonShorthand = slot.optional< | ||
| ExtractSlotProps<NonNullable<SplitButtonSlots['primaryActionButton']>> |
Contributor
There was a problem hiding this comment.
the same as above, pls use slot from props
| appearance, | ||
| children, | ||
| disabled, | ||
| disabledFocusable, |
Contributor
There was a problem hiding this comment.
disabledFocusable, icon, iconPosition are not HMTML button attributes
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.
Summary
PR 2 of a 3-PR stack. Base: #36523.
Extracts a design-agnostic
useSplitButtonBase_unstablebase hook (plusSplitButtonBaseProps/SplitButtonBaseSlots/SplitButtonBaseState) out of the styleduseSplitButton_unstable, so a future headlessSplitButton(PR 3) can compose the same behavior with headlessButton/MenuButtoninstead of the styled ones.Stack:
@fluentui/react-buttonbase-hook extractionfeat/split-button-headless— headlessSplitButton(base: this branch)What changed
SplitButton.types.ts: addedSplitButtonBaseSlots,SplitButtonBaseProps,SplitButtonBaseState— component-agnostic, typed againstButtonBaseProps/MenuButtonBasePropsinstead of concreteButton/MenuButton. Existing styled types (SplitButtonSlots/SplitButtonProps/SplitButtonState) are unchanged.useSplitButton.ts: addeduseSplitButtonBase_unstable, which owns all design-agnostic behavior (generated primary-action id,aria-labelledbyfallback naming, disabled/disabledFocusable propagation, icon propagation). RefactoreduseSplitButton_unstableto call the base hook and recreate both child slots viaslot.optionalwith the styledButton/MenuButtonelement types (production rendering resolves each slot's element type from itsSLOT_ELEMENT_TYPE_SYMBOLmetadata, not fromstate.components, so recreating rather than patchingstate.componentsis required).useSplitButtonBase.test.tsx(16 tests) for the new base contract.useSplitButtonBase.fixture.jsbundle-size fixture.react-button.api.md.No behavior change to the styled
SplitButton/useSplitButton_unstable— the regression tests added in #36523 continue to pass unmodified.