File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ For more information about controlled and uncontrolled mode of react-tabs see th
99
99
} ;
100
100
101
101
if ( newState . mode === MODE_UNCONTROLLED ) {
102
- const maxTabIndex = getTabsCount ( props . children ) - 1 ;
102
+ const maxTabIndex = Math . max ( 0 , getTabsCount ( props . children ) - 1 ) ;
103
103
let selectedIndex = null ;
104
104
105
105
if ( state . selectedIndex != null ) {
Original file line number Diff line number Diff line change @@ -541,4 +541,21 @@ describe('<Tabs />', () => {
541
541
expect ( firstTab ) . toHaveFocus ( ) ;
542
542
assertTabSelected ( 1 ) ;
543
543
} ) ;
544
+
545
+ test ( 'should render first tab once tabs are available' , ( ) => {
546
+ const { rerender } = render ( < Tabs > </ Tabs > ) ;
547
+
548
+ rerender (
549
+ < Tabs >
550
+ < TabList >
551
+ < Tab data-testid = "tab1" > Tab1</ Tab >
552
+ < Tab data-testid = "tab2" > Tab2</ Tab >
553
+ </ TabList >
554
+ < TabPanel data-testid = "panel1" > Hello Tab1</ TabPanel >
555
+ < TabPanel data-testid = "panel2" > Hello Tab2</ TabPanel >
556
+ </ Tabs > ,
557
+ ) ;
558
+
559
+ assertTabSelected ( 1 ) ;
560
+ } ) ;
544
561
} ) ;
You can’t perform that action at this time.
0 commit comments