@@ -23,12 +23,17 @@ import {
2323 homeKey ,
2424 spaceBar ,
2525} from '../common/controllers/key-bindings.js' ;
26+ import { first , last } from '../common/util.js' ;
2627import { simulateClick , simulateKeyboard } from '../common/utils.spec.js' ;
2728
2829describe ( 'Tabs component' , ( ) => {
2930 // Helper functions
3031 const getTabs = ( tabs : IgcTabsComponent ) =>
31- Array . from ( tabs . querySelectorAll ( IgcTabComponent . tagName ) ) ;
32+ Array . from (
33+ tabs . querySelectorAll < IgcTabComponent > (
34+ `:scope > ${ IgcTabComponent . tagName } `
35+ )
36+ ) ;
3237
3338 const getPanels = ( tabs : IgcTabsComponent ) =>
3439 Array . from ( tabs . querySelectorAll ( IgcTabPanelComponent . tagName ) ) ;
@@ -670,4 +675,42 @@ describe('Tabs component', () => {
670675 expect ( ( ) => tabs . appendChild ( tab ) ) . not . to . throw ( ) ;
671676 } ) ;
672677 } ) ;
678+
679+ describe ( 'issue-713' , ( ) => {
680+ it ( 'Nested tabs selection' , async ( ) => {
681+ const tabs = await fixture < IgcTabsComponent > ( html `
682+ < igc-tabs >
683+ < igc-tab > 1</ igc-tab >
684+ < igc-tab > 2</ igc-tab >
685+ < igc-tab-panel >
686+ Panel 1
687+ < igc-tabs >
688+ < igc-tab > 1.1</ igc-tab >
689+ < igc-tab selected > 1.2</ igc-tab >
690+ < igc-tab-panel > Panel 1.1</ igc-tab-panel >
691+ < igc-tab-panel > Panel 1.2</ igc-tab-panel >
692+ </ igc-tabs >
693+ </ igc-tab-panel >
694+ < igc-tab-panel > Panel 2</ igc-tab-panel >
695+ </ igc-tabs >
696+ ` ) ;
697+
698+ const nestedTabs = tabs . querySelector ( IgcTabsComponent . tagName ) ! ;
699+
700+ expect ( getSelectedTab ( tabs ) . textContent ) . to . equal ( '1' ) ;
701+ expect ( getSelectedTab ( nestedTabs ) . textContent ) . to . equal ( '1.2' ) ;
702+
703+ simulateClick ( first ( getTabs ( nestedTabs ) ) ) ;
704+ await elementUpdated ( tabs ) ;
705+
706+ expect ( getSelectedTab ( tabs ) . textContent ) . to . equal ( '1' ) ;
707+ expect ( getSelectedTab ( nestedTabs ) . textContent ) . to . equal ( '1.1' ) ;
708+
709+ simulateClick ( last ( getTabs ( tabs ) ) ) ;
710+ await elementUpdated ( tabs ) ;
711+
712+ expect ( getSelectedTab ( tabs ) . textContent ) . to . equal ( '2' ) ;
713+ expect ( getSelectedTab ( nestedTabs ) . textContent ) . to . equal ( '1.1' ) ;
714+ } ) ;
715+ } ) ;
673716} ) ;
0 commit comments