diff --git a/packages/components/src/button/index.tsx b/packages/components/src/button/index.tsx index b60f6af039e59..e2ef34f35712e 100644 --- a/packages/components/src/button/index.tsx +++ b/packages/components/src/button/index.tsx @@ -174,14 +174,16 @@ export function UnforwardedButton( const anchorProps: ComponentPropsWithoutRef< 'a' > = Tag === 'a' ? { href, target } : {}; + const disableEventProps: { + [ key: string ]: ( event: MouseEvent ) => void; + } = {}; if ( disabled && isFocusable ) { // In this case, the button will be disabled, but still focusable and // perceivable by screen reader users. buttonProps[ 'aria-disabled' ] = true; anchorProps[ 'aria-disabled' ] = true; - for ( const disabledEvent of disabledEventsOnDisabledButton ) { - additionalProps[ disabledEvent ] = ( event: MouseEvent ) => { + disableEventProps[ disabledEvent ] = ( event: MouseEvent ) => { if ( event ) { event.stopPropagation(); event.preventDefault(); @@ -234,6 +236,7 @@ export function UnforwardedButton( ) } + { ...disableEventProps } { ...commonProps } > { elementChildren } @@ -242,6 +245,7 @@ export function UnforwardedButton(