Skip to content

Commit 0e1c7f2

Browse files
CopilotLipata
andcommitted
docs(tabs): update README to document tabs without content behavior
Co-authored-by: Lipata <[email protected]>
1 parent d745c3b commit 0e1c7f2

File tree

2 files changed

+71
-3
lines changed

2 files changed

+71
-3
lines changed

projects/igniteui-angular/src/lib/tabs/tabs/README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
## Description
44
_igx-tabs component allows you to add a tabs component with tab items, positioned at the top, and item content in your application. The tabs in Ignite UI for Angular can be composed with the following components and directives:_
55

6-
- *igx-tab-item* - single content area that holds header and content components
6+
- *igx-tab-item* - single content area that holds header and optionally content components
77
- *igx-tab-header* - holds the title and/or icon of the item and you can add them with `igxTabHeaderIcon` and `igxTabHeaderLabel`
8-
- *igx-tab-content* - represents the wrapper of the content that needs to be displayed
8+
- *igx-tab-content* - represents the wrapper of the content that needs to be displayed (optional)
99

10-
Each item (`igx-tab-item`) contains header (`igx-tab-header`) and content (`igx-tab-content`). When a tab is clicked, the associated content is selected and visualized into a single container. There should always be a selected tab. Only one tab can be selected at a time.
10+
Each item (`igx-tab-item`) contains a header (`igx-tab-header`) and optionally content (`igx-tab-content`). When a tab is clicked, the associated content is selected and visualized into a single container. If a tab has no content, it can still be selected and used for navigation purposes. There should always be a selected tab. Only one tab can be selected at a time.
1111
A walkthrough of how to get started can be found [here](https://www.infragistics.com/products/ignite-ui-angular/angular/components/tabs).
1212

1313
----------
@@ -59,6 +59,33 @@ A walkthrough of how to get started can be found [here](https://www.infragistics
5959
</igx-tab-item>
6060
</igx-tabs>
6161

62+
## Tabs without content (Navigation-only)
63+
64+
For navigation purposes, you can create tabs without content:
65+
66+
<igx-tabs>
67+
<igx-tab-item>
68+
<igx-tab-header igxRipple>
69+
<igx-icon igxTabHeaderIcon>home</igx-icon>
70+
<span igxTabHeaderLabel>Home</span>
71+
</igx-tab-header>
72+
</igx-tab-item>
73+
74+
<igx-tab-item [selected]="true">
75+
<igx-tab-header igxRipple>
76+
<igx-icon igxTabHeaderIcon>info</igx-icon>
77+
<span igxTabHeaderLabel>About</span>
78+
</igx-tab-header>
79+
</igx-tab-item>
80+
81+
<igx-tab-item>
82+
<igx-tab-header igxRipple>
83+
<igx-icon igxTabHeaderIcon>contact_page</igx-icon>
84+
<span igxTabHeaderLabel>Contact</span>
85+
</igx-tab-header>
86+
</igx-tab-item>
87+
</igx-tabs>
88+
6289

6390
# API Summary
6491

projects/igniteui-angular/src/lib/tabs/tabs/tabs.component.spec.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,47 @@ describe('IgxTabs', () => {
944944
expect(tabItems[2].selected).toBe(false);
945945
}));
946946

947+
it('should fire events when clicking on tabs without content', fakeAsync(() => {
948+
// Set up a clean test with the first test group (tab 2 initially selected)
949+
fixture = TestBed.createComponent(TabsTabsOnlyModeTest1Component);
950+
tabsComp = fixture.componentInstance.tabs;
951+
fixture.detectChanges();
952+
tabItems = tabsComp.items.toArray();
953+
headerElements = tabItems.map(item => item.headerComponent.nativeElement);
954+
955+
const indexChangingSpy = spyOn(tabsComp.selectedIndexChanging, 'emit');
956+
const indexChangeSpy = spyOn(tabsComp.selectedIndexChange, 'emit');
957+
const itemChangeSpy = spyOn(tabsComp.selectedItemChange, 'emit');
958+
959+
tick(100);
960+
fixture.detectChanges();
961+
962+
// Initially Tab 2 should be selected (index 1)
963+
expect(tabsComp.selectedIndex).toBe(1);
964+
965+
// Click on Tab 1 (which has no content)
966+
headerElements[0].dispatchEvent(new Event('click', { bubbles: true }));
967+
tick(200);
968+
fixture.detectChanges();
969+
970+
// Tab should be selected
971+
expect(tabsComp.selectedIndex).toBe(0);
972+
973+
// Events should have fired
974+
expect(indexChangingSpy).toHaveBeenCalledWith({
975+
owner: tabsComp,
976+
cancel: false,
977+
oldIndex: 1,
978+
newIndex: 0
979+
});
980+
expect(indexChangeSpy).toHaveBeenCalledWith(0);
981+
expect(itemChangeSpy).toHaveBeenCalledWith({
982+
owner: tabsComp,
983+
oldItem: tabItems[1],
984+
newItem: tabItems[0]
985+
});
986+
}));
987+
947988
});
948989

949990
describe('Events', () => {

0 commit comments

Comments
 (0)