Skip to content

Commit

Permalink
Make disabled button component more accessible through aria-disabled (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nats12 authored Apr 28, 2021
1 parent c1421a4 commit 7461c9c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/button/button.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
background-color: transparent;
padding: 0;

&:disabled {
&[aria-disabled='true'] {
opacity: 0.4;
cursor: not-allowed;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(
ref={ref}
type={type}
className={className}
disabled={disabled || loading}
onClick={onClick}
aria-disabled={disabled || loading}
onClick={disabled || loading ? undefined : onClick}
>
{children}
</button>
Expand Down
6 changes: 3 additions & 3 deletions src/components/dropdown/__snapshots__/dropdown.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ exports[`Dropdown Dropdown.Box renders the Body component first when top prop is
size="default"
>
<button
aria-disabled={false}
className="reactist_button trigger"
disabled={false}
onClick={[Function]}
type="button"
/>
Expand Down Expand Up @@ -134,8 +134,8 @@ exports[`Dropdown Dropdown.Box renders the Trigger component first when top prop
size="default"
>
<button
aria-disabled={false}
className="reactist_button trigger"
disabled={false}
onClick={[Function]}
type="button"
/>
Expand Down Expand Up @@ -192,8 +192,8 @@ exports[`Dropdown Dropdown.Box renders the Trigger component without crashing 1`
size="default"
>
<button
aria-disabled={false}
className="reactist_button trigger"
disabled={false}
onClick={[Function]}
type="button"
/>
Expand Down

0 comments on commit 7461c9c

Please sign in to comment.