diff --git a/.changeset/cuddly-rules-taste.md b/.changeset/cuddly-rules-taste.md new file mode 100644 index 00000000000..26d35b61477 --- /dev/null +++ b/.changeset/cuddly-rules-taste.md @@ -0,0 +1,5 @@ +--- +'@primer/react': minor +--- + +update types for button extensions diff --git a/src/ActionList/Item.tsx b/src/ActionList/Item.tsx index ab7cc7c1867..4aef1c765c1 100644 --- a/src/ActionList/Item.tsx +++ b/src/ActionList/Item.tsx @@ -10,6 +10,7 @@ import {ActionListGroupProps, GroupContext} from './Group' import {ActionListProps, ListContext} from './List' import {Selection} from './Selection' import {ActionListItemProps, Slots, TEXT_ROW_HEIGHT, getVariantStyles} from './shared' +import {defaultSxProp} from '../utils/defaultSxProp' const LiBox = styled.li(sx) @@ -21,7 +22,7 @@ export const Item = React.forwardRef( selected = undefined, active = false, onSelect, - sx: sxProp = {}, + sx: sxProp = defaultSxProp, id, role, _PrivateItemWrapper, diff --git a/src/ActionList/List.tsx b/src/ActionList/List.tsx index af89165ce7f..29bc2f54953 100644 --- a/src/ActionList/List.tsx +++ b/src/ActionList/List.tsx @@ -4,6 +4,7 @@ import styled from 'styled-components' import sx, {SxProp, merge} from '../sx' import {AriaRole} from '../utils/types' import {ActionListContainerContext} from './ActionListContainerContext' +import {defaultSxProp} from '../utils/defaultSxProp' export type ActionListProps = React.PropsWithChildren<{ /** @@ -32,7 +33,7 @@ const ListBox = styled.ul(sx) export const List = React.forwardRef( ( - {variant = 'inset', selectionVariant, showDividers = false, role, sx: sxProp = {}, ...props}, + {variant = 'inset', selectionVariant, showDividers = false, role, sx: sxProp = defaultSxProp, ...props}, forwardedRef, ): JSX.Element => { const styles = { diff --git a/src/ActionMenu.tsx b/src/ActionMenu.tsx index d36ce4dcf9c..4409a07d988 100644 --- a/src/ActionMenu.tsx +++ b/src/ActionMenu.tsx @@ -8,6 +8,7 @@ import {ActionListContainerContext} from './ActionList/ActionListContainerContex import {Button, ButtonProps} from './Button' import {useId} from './hooks/useId' import {MandateProps} from './utils/types' +import {ForwardRefComponent as PolymorphicForwardRefComponent} from './utils/polymorphic' export type MenuContextProps = Pick< AnchoredOverlayProps, @@ -67,21 +68,19 @@ const Menu: React.FC> = ({ } export type ActionMenuAnchorProps = {children: React.ReactElement} -const Anchor = React.forwardRef( - ({children, ...anchorProps}, anchorRef) => { - return React.cloneElement(children, {...anchorProps, ref: anchorRef}) - }, -) +const Anchor = React.forwardRef(({children, ...anchorProps}, anchorRef) => { + return React.cloneElement(children, {...anchorProps, ref: anchorRef}) +}) /** this component is syntactical sugar 🍭 */ export type ActionMenuButtonProps = ButtonProps -const MenuButton = React.forwardRef(({...props}, anchorRef) => { +const MenuButton = React.forwardRef((props, anchorRef) => { return ( } export function ShouldAcceptKnownButtonPropsAndDomProps() { - const buttonEl = useRef() + const buttonEl = useRef(null) return (