Skip to content

Commit

Permalink
docs: Adding example of how to pass on click to primaryActionButton s…
Browse files Browse the repository at this point in the history
…lot in the Default story for SplitButton (#29334)

* docs: Adding example of how to pass on click to primaryActionButton slot in the Default story for SplitButton.

* Adding change file.
  • Loading branch information
khmakoto authored Sep 29, 2023
1 parent 0b1addb commit d54dc8a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "docs: Adding example of how to pass on click to primaryActionButton slot in the Default story for SplitButton.",
"packageName": "@fluentui/react-button",
"email": "Humberto.Morimoto@microsoft.com",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ export const useSplitButton_unstable = (
},
renderByDefault: true,
elementType: Button,
}); // Resolve menu button's aria-labelledby to be labelled by the primary action button if not a label was not provided
// by the user.
});

// Resolve menu button's aria-labelledby to be labelled by the primary action button if no label was provided by the
// user.
if (
menuButtonShorthand &&
primaryActionButtonShorthand &&
Expand All @@ -65,6 +67,7 @@ export const useSplitButton_unstable = (
) {
menuButtonShorthand['aria-labelledby'] = primaryActionButtonShorthand.id;
}

return {
// Props passed at the top-level
appearance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@ import * as React from 'react';
import { Menu, MenuItem, MenuList, MenuPopover, MenuTrigger, SplitButton } from '@fluentui/react-components';
import type { MenuButtonProps } from '@fluentui/react-components';

const onClick = () => alert('Primary action button clicked.');

const primaryActionButtonProps = {
onClick,
};

export const Default = () => (
<Menu positioning="below-end">
<MenuTrigger disableButtonEnhancement>
{(triggerProps: MenuButtonProps) => <SplitButton menuButton={triggerProps}>Example</SplitButton>}
{(triggerProps: MenuButtonProps) => (
<SplitButton menuButton={triggerProps} primaryActionButton={primaryActionButtonProps}>
Example
</SplitButton>
)}
</MenuTrigger>

<MenuPopover>
Expand Down

0 comments on commit d54dc8a

Please sign in to comment.