File tree 3 files changed +17
-1
lines changed
docusaurus-theme-classic/src/theme/Tabs
docusaurus-theme-common/src/utils
3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -187,4 +187,16 @@ describe('Tabs', () => {
187
187
) ;
188
188
} ) . not . toThrow ( ) ;
189
189
} ) ;
190
+
191
+ it ( 'accepts a single TabItem' , ( ) => {
192
+ expect ( ( ) => {
193
+ renderer . create (
194
+ < TestProviders >
195
+ < Tabs >
196
+ < TabItem value = "val1" > Val1</ TabItem >
197
+ </ Tabs >
198
+ </ TestProviders > ,
199
+ ) ;
200
+ } ) . not . toThrow ( ) ;
201
+ } ) ;
190
202
} ) ;
Original file line number Diff line number Diff line change @@ -109,6 +109,8 @@ function TabContent({
109
109
children,
110
110
selectedValue,
111
111
} : Props & ReturnType < typeof useTabs > ) {
112
+ // eslint-disable-next-line no-param-reassign
113
+ children = Array . isArray ( children ) ? children : [ children ] ;
112
114
if ( lazy ) {
113
115
const selectedTabItem = children . find (
114
116
( tabItem ) => tabItem . props . value === selectedValue ,
Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ export interface TabValue {
32
32
export interface TabsProps {
33
33
readonly lazy ?: boolean ;
34
34
readonly block ?: boolean ;
35
- readonly children : readonly ReactElement < TabItemProps > [ ] ;
35
+ readonly children :
36
+ | readonly ReactElement < TabItemProps > [ ]
37
+ | ReactElement < TabItemProps > ;
36
38
readonly defaultValue ?: string | null ;
37
39
readonly values ?: readonly TabValue [ ] ;
38
40
readonly groupId ?: string ;
You can’t perform that action at this time.
0 commit comments