Skip to content

Commit

Permalink
fix: linkの時だけaria-disabledが付くように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
toshusai committed Oct 20, 2023
1 parent 0d4a492 commit da84270
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/react/src/components/Clickable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ export type ClickableElement = HTMLButtonElement & HTMLAnchorElement
const Clickable = React.forwardRef<ClickableElement, ClickableProps>(
function Clickable(props, ref) {
const { Link } = useComponentAbstraction()
const as = 'to' in props ? Link : 'button'
return <StyledClickableDiv {...props} ref={ref} as={as} aria-disabled={props.disabled} />
const isLink = 'to' in props
const as = isLink ? Link : 'button'
const ariaDisabled = isLink && props.disabled === true ? true : undefined
return (
<StyledClickableDiv
{...props}
ref={ref}
as={as}
aria-disabled={ariaDisabled}
/>
)
}
)
export default Clickable
Expand Down

0 comments on commit da84270

Please sign in to comment.