File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ const Anchor = React.forwardRef<HTMLAnchorElement, AnchorProps>(
32
32
} ,
33
33
) ;
34
34
35
- if ( ( isTrivialHref ( props . href ) && ! props . role ) || props . role === 'button' ) {
35
+ if ( isTrivialHref ( props . href ) || props . role === 'button' ) {
36
36
return (
37
37
< a ref = { ref } { ...props } { ...buttonProps } onKeyDown = { handleKeyDown } />
38
38
) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export interface UseButtonPropsOptions extends AnchorOptions {
14
14
onClick ?: React . EventHandler < React . MouseEvent | React . KeyboardEvent > ;
15
15
tabIndex ?: number ;
16
16
tagName ?: keyof JSX . IntrinsicElements ;
17
+ role ?: React . AriaRole | undefined ;
17
18
}
18
19
19
20
export function isTrivialHref ( href ?: string ) {
@@ -23,7 +24,7 @@ export function isTrivialHref(href?: string) {
23
24
export interface AriaButtonProps {
24
25
type ?: ButtonType | undefined ;
25
26
disabled : boolean | undefined ;
26
- role ?: 'button' ;
27
+ role ?: React . AriaRole ;
27
28
tabIndex ?: number | undefined ;
28
29
href ?: string | undefined ;
29
30
target ?: string | undefined ;
@@ -43,6 +44,7 @@ export function useButtonProps({
43
44
href,
44
45
target,
45
46
rel,
47
+ role,
46
48
onClick,
47
49
tabIndex = 0 ,
48
50
type,
@@ -90,7 +92,7 @@ export function useButtonProps({
90
92
91
93
return [
92
94
{
93
- role : 'button' ,
95
+ role : role ?? 'button' ,
94
96
// explicitly undefined so that it overrides the props disabled in a spread
95
97
// e.g. <Tag {...props} {...hookProps} />
96
98
disabled : undefined ,
You can’t perform that action at this time.
0 commit comments