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>(
3232 } ,
3333 ) ;
3434
35- if ( ( isTrivialHref ( props . href ) && ! props . role ) || props . role === 'button' ) {
35+ if ( isTrivialHref ( props . href ) || props . role === 'button' ) {
3636 return (
3737 < a ref = { ref } { ...props } { ...buttonProps } onKeyDown = { handleKeyDown } />
3838 ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export interface UseButtonPropsOptions extends AnchorOptions {
1414 onClick ?: React . EventHandler < React . MouseEvent | React . KeyboardEvent > ;
1515 tabIndex ?: number ;
1616 tagName ?: keyof JSX . IntrinsicElements ;
17+ role ?: React . AriaRole | undefined ;
1718}
1819
1920export function isTrivialHref ( href ?: string ) {
@@ -23,7 +24,7 @@ export function isTrivialHref(href?: string) {
2324export interface AriaButtonProps {
2425 type ?: ButtonType | undefined ;
2526 disabled : boolean | undefined ;
26- role ?: 'button' ;
27+ role ?: React . AriaRole ;
2728 tabIndex ?: number | undefined ;
2829 href ?: string | undefined ;
2930 target ?: string | undefined ;
@@ -43,6 +44,7 @@ export function useButtonProps({
4344 href,
4445 target,
4546 rel,
47+ role,
4648 onClick,
4749 tabIndex = 0 ,
4850 type,
@@ -90,7 +92,7 @@ export function useButtonProps({
9092
9193 return [
9294 {
93- role : 'button' ,
95+ role : role ?? 'button' ,
9496 // explicitly undefined so that it overrides the props disabled in a spread
9597 // e.g. <Tag {...props} {...hookProps} />
9698 disabled : undefined ,
You can’t perform that action at this time.
0 commit comments