@@ -13,10 +13,12 @@ const TabContainer = styled.div`
1313 flex-direction: column;
1414` ;
1515
16- const TabLink = styled . a < {
17- disabled : TabProps [ "disabled" ] ;
18- iconPosition : NavTabsPropsType [ "iconPosition" ] ;
19- } > `
16+ const TabLink = styled . div <
17+ {
18+ disabled : TabProps [ "disabled" ] ;
19+ iconPosition : NavTabsPropsType [ "iconPosition" ] ;
20+ } & React . AnchorHTMLAttributes < HTMLAnchorElement >
21+ > `
2022 box-sizing: border-box;
2123 display: flex;
2224 flex-direction: ${ ( { iconPosition } ) => ( iconPosition === "top" ? "column" : "row" ) } ;
@@ -96,11 +98,11 @@ const Tab = forwardRef(
9698 notificationNumber = false ,
9799 ...otherProps
98100 } : TabProps ,
99- ref : Ref < HTMLAnchorElement >
101+ ref : Ref < HTMLAnchorElement | HTMLDivElement >
100102 ) => {
101103 const { iconPosition, tabIndex, focusedLabel } = useContext ( NavTabsContext ) ?? { } ;
102- const tabRef = useRef < HTMLAnchorElement > ( ) ;
103- const innerRef = useRef < HTMLAnchorElement | null > ( null ) ;
104+ const tabRef = useRef < HTMLAnchorElement | HTMLDivElement | null > ( ) ;
105+ const innerRef = useRef < HTMLAnchorElement | HTMLDivElement | null > ( null ) ;
104106 useImperativeHandle ( ref , ( ) => innerRef . current ! , [ ] ) ;
105107
106108 useEffect ( ( ) => {
@@ -109,7 +111,7 @@ const Tab = forwardRef(
109111 }
110112 } , [ children , focusedLabel ] ) ;
111113
112- const handleOnKeyDown = ( event : KeyboardEvent < HTMLAnchorElement > ) => {
114+ const handleOnKeyDown = ( event : KeyboardEvent < HTMLDivElement | HTMLAnchorElement > ) => {
113115 switch ( event . key ) {
114116 case " " :
115117 case "Enter" :
@@ -128,11 +130,12 @@ const Tab = forwardRef(
128130 aria-disabled = { disabled }
129131 aria-selected = { active }
130132 disabled = { disabled }
133+ as = { href ? "a" : onClick ? "button" : "div" }
131134 href = { ! disabled ? href : undefined }
135+ onClick = { ! disabled ? onClick : undefined }
132136 iconPosition = { iconPosition }
133- onClick = { onClick }
134137 onKeyDown = { handleOnKeyDown }
135- ref = { ( anchorRef : HTMLAnchorElement ) => {
138+ ref = { ( anchorRef : HTMLAnchorElement | HTMLDivElement | null ) => {
136139 tabRef . current = anchorRef ;
137140 if ( ref ) {
138141 if ( typeof ref === "function" ) ref ( anchorRef ) ;
0 commit comments