File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,21 +40,24 @@ export const Tabs: React.FC<TabsProps> = ({
4040 const currentIndex = tabs . findIndex ( ( t ) => t . key === effectiveActiveKey ) ;
4141 if ( key . leftArrow || input === "h" ) {
4242 for ( let i = currentIndex - 1 ; i >= 0 ; i -- ) {
43- if ( ! tabs [ i ] . disabled ) {
44- onChange ( tabs [ i ] . key ) ;
43+ const tab = tabs [ i ] ;
44+ if ( tab && ! tab . disabled ) {
45+ onChange ( tab . key ) ;
4546 break ;
4647 }
4748 }
4849 } else if ( key . rightArrow || input === "l" ) {
4950 for ( let i = currentIndex + 1 ; i < tabs . length ; i ++ ) {
50- if ( ! tabs [ i ] . disabled ) {
51- onChange ( tabs [ i ] . key ) ;
51+ const tab = tabs [ i ] ;
52+ if ( tab && ! tab . disabled ) {
53+ onChange ( tab . key ) ;
5254 break ;
5355 }
5456 }
5557 } else if ( input >= "1" && input <= "9" ) {
5658 const idx = parseInt ( input , 10 ) - 1 ;
57- if ( idx < tabs . length && ! tabs [ idx ] . disabled ) onChange ( tabs [ idx ] . key ) ;
59+ const tab = tabs [ idx ] ;
60+ if ( idx < tabs . length && tab && ! tab . disabled ) onChange ( tab . key ) ;
5861 }
5962 } ,
6063 { isActive : focus } ,
You can’t perform that action at this time.
0 commit comments