Skip to content

Commit 26bad2a

Browse files
committed
refactor setting of disabled props
1 parent e628ef3 commit 26bad2a

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

packages/react/src/Button/Button.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,6 @@ export const _Button = forwardRef(
153153
[isDisabled, onBlur],
154154
)
155155

156-
let disabledProp
157-
158-
if (isDisabled) {
159-
disabledProp = Component === 'button' ? {disabled: true} : {'aria-disabled': true}
160-
}
161-
162156
return (
163157
<Component
164158
ref={ref}
@@ -175,7 +169,8 @@ export const _Button = forwardRef(
175169
onMouseLeave={handleOnMouseLeave}
176170
onFocus={handleOnFocus}
177171
onBlur={handleOnBlur}
178-
{...disabledProp}
172+
disabled={(isDisabled && Component === 'button') || undefined}
173+
aria-disabled={(isDisabled && Component !== 'button') || undefined}
179174
style={{...animationInlineStyles, ...style}}
180175
{...props}
181176
>

0 commit comments

Comments
 (0)