diff --git a/.changeset/cuddly-rice-press.md b/.changeset/cuddly-rice-press.md new file mode 100644 index 00000000000..b35405b4578 --- /dev/null +++ b/.changeset/cuddly-rice-press.md @@ -0,0 +1,7 @@ +--- +'@primer/react': patch +--- + +Update the `children` prop for `Button` to be optional + + diff --git a/src/ActionMenu.tsx b/src/ActionMenu.tsx index f2494987c16..2f55d4332ea 100644 --- a/src/ActionMenu.tsx +++ b/src/ActionMenu.tsx @@ -73,7 +73,9 @@ const Anchor = React.forwardRef(({children, }) /** this component is syntactical sugar 🍭 */ -export type ActionMenuButtonProps = ButtonProps +export type ActionMenuButtonProps = ButtonProps & { + children: React.ReactNode +} const MenuButton = React.forwardRef(({...props}, anchorRef) => { return ( diff --git a/src/ActionMenu/ActionMenu.tsx b/src/ActionMenu/ActionMenu.tsx index 57495318a4a..b84b1a6541a 100644 --- a/src/ActionMenu/ActionMenu.tsx +++ b/src/ActionMenu/ActionMenu.tsx @@ -73,7 +73,9 @@ const Anchor = React.forwardRef(({children, }) /** this component is syntactical sugar 🍭 */ -export type ActionMenuButtonProps = ButtonProps +export type ActionMenuButtonProps = Omit & { + children: React.ReactNode +} const MenuButton = React.forwardRef(({...props}, anchorRef) => { return ( diff --git a/src/Button/__tests__/Button.types.test.tsx b/src/Button/__tests__/Button.types.test.tsx index 29e813162d2..e7348b99d9c 100644 --- a/src/Button/__tests__/Button.types.test.tsx +++ b/src/Button/__tests__/Button.types.test.tsx @@ -69,6 +69,10 @@ export function iconButtonShouldNotAcceptOutlandishProps() { return } diff --git a/src/Button/types.ts b/src/Button/types.ts index bd8d96f293b..41e91c4acda 100644 --- a/src/Button/types.ts +++ b/src/Button/types.ts @@ -69,7 +69,7 @@ export type ButtonProps = { */ trailingAction?: React.ElementType | null - children: React.ReactNode + children?: React.ReactNode /** * Content alignment for when visuals are present diff --git a/src/__tests__/ActionMenu.types.test.tsx b/src/__tests__/ActionMenu.types.test.tsx index 38e954a5754..5e26f333e7f 100644 --- a/src/__tests__/ActionMenu.types.test.tsx +++ b/src/__tests__/ActionMenu.types.test.tsx @@ -2,7 +2,7 @@ import {ActionMenu} from '..' import React from 'react' export function actionButtonWithoutProps() { - //@ts-expect-error requires children + // @ts-expect-error requires children return }