File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed
packages/graphiql/src/components Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -538,7 +538,7 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
538538 onReorder = { handleReorder }
539539 aria-label = "Select active operation"
540540 >
541- { editorContext . tabs . map ( ( tab , index ) => (
541+ { editorContext . tabs . map ( ( tab , index , tabs ) => (
542542 < Tab
543543 key = { tab . id }
544544 value = { tab }
@@ -556,14 +556,16 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
556556 { tab . title }
557557 </ Tab . Button >
558558 </ Tooltip >
559- < Tab . Close
560- onClick = { ( ) => {
561- if ( editorContext . activeTabIndex === index ) {
562- executionContext . stop ( ) ;
563- }
564- editorContext . closeTab ( index ) ;
565- } }
566- />
559+ { tabs . length > 1 && (
560+ < Tab . Close
561+ onClick = { ( ) => {
562+ if ( editorContext . activeTabIndex === index ) {
563+ executionContext . stop ( ) ;
564+ }
565+ editorContext . closeTab ( index ) ;
566+ } }
567+ />
568+ ) }
567569 </ Tab >
568570 ) ) }
569571 </ Tabs >
Original file line number Diff line number Diff line change @@ -410,13 +410,13 @@ describe('GraphiQL', () => {
410410 } ) ;
411411
412412 describe ( 'Tabs' , ( ) => {
413- it ( 'show tabs if there are more than one ' , async ( ) => {
413+ it ( 'show tabs' , async ( ) => {
414414 const { container } = render ( < GraphiQL fetcher = { noOpFetcher } /> ) ;
415415
416416 await waitFor ( ( ) => {
417417 expect (
418418 container . querySelectorAll ( '.graphiql-tabs .graphiql-tab' ) ,
419- ) . toHaveLength ( 0 ) ;
419+ ) . toHaveLength ( 1 ) ;
420420 } ) ;
421421
422422 act ( ( ) => {
@@ -492,7 +492,7 @@ describe('GraphiQL', () => {
492492 await waitFor ( ( ) => {
493493 expect (
494494 container . querySelectorAll ( '.graphiql-tabs .graphiql-tab' ) ,
495- ) . toHaveLength ( 0 ) ;
495+ ) . toHaveLength ( 1 ) ;
496496 expect (
497497 container . querySelectorAll ( '.graphiql-tab .graphiql-tab-close' ) ,
498498 ) . toHaveLength ( 0 ) ;
You can’t perform that action at this time.
0 commit comments