Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: React compiler error on button. #61958

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/components/src/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -234,6 +236,7 @@ export function UnforwardedButton(
<a
{ ...anchorProps }
{ ...( additionalProps as HTMLAttributes< HTMLAnchorElement > ) }
{ ...disableEventProps }
{ ...commonProps }
>
{ elementChildren }
Expand All @@ -242,6 +245,7 @@ export function UnforwardedButton(
<button
{ ...buttonProps }
{ ...( additionalProps as HTMLAttributes< HTMLButtonElement > ) }
{ ...disableEventProps }
{ ...commonProps }
>
{ elementChildren }
Expand Down
Loading