diff --git a/.changeset/lazy-crabs-pay.md b/.changeset/lazy-crabs-pay.md new file mode 100644 index 00000000000..e8dbe3a9cf5 --- /dev/null +++ b/.changeset/lazy-crabs-pay.md @@ -0,0 +1,5 @@ +--- +"@kaizen/components": patch +--- + +Pass onClick through to MenuItem even when it is rendered as a link diff --git a/packages/components/src/Menu/_docs/MenuContentExample.tsx b/packages/components/src/Menu/_docs/MenuContentExample.tsx index 6f5bee4cbb9..1537b546121 100644 --- a/packages/components/src/Menu/_docs/MenuContentExample.tsx +++ b/packages/components/src/Menu/_docs/MenuContentExample.tsx @@ -26,7 +26,10 @@ export const MenuContentExample = ({ Buttons}> + e: React.MouseEvent< + HTMLButtonElement | HTMLAnchorElement, + MouseEvent + > ): void => { alert("Hello") e.preventDefault() @@ -36,7 +39,10 @@ export const MenuContentExample = ({ /> + e: React.MouseEvent< + HTMLButtonElement | HTMLAnchorElement, + MouseEvent + > ): void => { e.preventDefault() }} @@ -45,7 +51,10 @@ export const MenuContentExample = ({ /> + e: React.MouseEvent< + HTMLButtonElement | HTMLAnchorElement, + MouseEvent + > ): void => { e.preventDefault() }} @@ -55,7 +64,10 @@ export const MenuContentExample = ({ /> + e: React.MouseEvent< + HTMLButtonElement | HTMLAnchorElement, + MouseEvent + > ): void => { e.preventDefault() }} @@ -65,7 +77,10 @@ export const MenuContentExample = ({ /> + e: React.MouseEvent< + HTMLButtonElement | HTMLAnchorElement, + MouseEvent + > ): void => { e.preventDefault() }} @@ -78,7 +93,10 @@ export const MenuContentExample = ({ Buttons (no icons)}> + e: React.MouseEvent< + HTMLButtonElement | HTMLAnchorElement, + MouseEvent + > ): void => { e.preventDefault() }} @@ -86,7 +104,10 @@ export const MenuContentExample = ({ /> + e: React.MouseEvent< + HTMLButtonElement | HTMLAnchorElement, + MouseEvent + > ): void => { e.preventDefault() }} diff --git a/packages/components/src/Menu/subcomponents/MenuItem/MenuItem.tsx b/packages/components/src/Menu/subcomponents/MenuItem/MenuItem.tsx index 146ef6def0b..b8e75abaf3a 100644 --- a/packages/components/src/Menu/subcomponents/MenuItem/MenuItem.tsx +++ b/packages/components/src/Menu/subcomponents/MenuItem/MenuItem.tsx @@ -7,7 +7,7 @@ export type MenuItemProps = { href?: string // Only applicable if href is supplied above target?: string - onClick?: (e: React.MouseEvent) => void + onClick?: (e: React.MouseEvent) => void icon?: JSX.Element destructive?: boolean disabled?: boolean @@ -70,6 +70,7 @@ export const MenuItem = ({