Skip to content

Commit 021a359

Browse files
committed
feat(Tabs): add tabListAriaLabel prop
Signed-off-by: Mohamed Fall <[email protected]>
1 parent bc46a52 commit 021a359

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

packages/react-core/src/components/Tabs/Tabs.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export interface TabsProps
6161
onAdd?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
6262
/** Aria-label for the add button */
6363
addButtonAriaLabel?: string;
64+
/** Aria-label for the list element */
65+
tabListAriaLabel?: string;
6466
/** Uniquely identifies the tabs */
6567
id?: string;
6668
/** Flag indicating that the add button is disabled when onAdd is passed in */
@@ -500,6 +502,7 @@ class Tabs extends Component<TabsProps, TabsState> {
500502
toggleText,
501503
toggleAriaLabel,
502504
addButtonAriaLabel,
505+
tabListAriaLabel,
503506
onToggle,
504507
onClose,
505508
onAdd,
@@ -626,7 +629,13 @@ class Tabs extends Component<TabsProps, TabsState> {
626629
/>
627630
</div>
628631
)}
629-
<ul className={css(styles.tabsList)} ref={this.tabList} onScroll={this.handleScrollButtons} role="tablist">
632+
<ul
633+
aria-label={tabListAriaLabel || 'Tab List'}
634+
className={css(styles.tabsList)}
635+
ref={this.tabList}
636+
onScroll={this.handleScrollButtons}
637+
role="tablist"
638+
>
630639
{isOverflowHorizontal ? filteredChildrenWithoutOverflow : filteredChildren}
631640
{hasOverflowTab && <OverflowTab overflowingTabs={overflowingTabProps} {...overflowObjectProps} />}
632641
</ul>

packages/react-core/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ exports[`should render accessible tabs 1`] = `
1212
style="--pf-v6-c-tabs--link-accent--length: 0px; --pf-v6-c-tabs--link-accent--start: 0px;"
1313
>
1414
<ul
15+
aria-label="Tab List"
1516
class="pf-v6-c-tabs__list"
1617
role="tablist"
1718
>
@@ -129,6 +130,7 @@ exports[`should render box tabs 1`] = `
129130
style="--pf-v6-c-tabs--link-accent--length: 0px; --pf-v6-c-tabs--link-accent--start: 0px;"
130131
>
131132
<ul
133+
aria-label="Tab List"
132134
class="pf-v6-c-tabs__list"
133135
role="tablist"
134136
>
@@ -288,6 +290,7 @@ exports[`should render box tabs of secondary variant 1`] = `
288290
style="--pf-v6-c-tabs--link-accent--length: 0px; --pf-v6-c-tabs--link-accent--start: 0px;"
289291
>
290292
<ul
293+
aria-label="Tab List"
291294
class="pf-v6-c-tabs__list"
292295
role="tablist"
293296
>
@@ -453,6 +456,7 @@ exports[`should render expandable vertical tabs 1`] = `
453456
</div>
454457
</div>
455458
<ul
459+
aria-label="Tab List"
456460
class="pf-v6-c-tabs__list"
457461
role="tablist"
458462
>
@@ -612,6 +616,7 @@ exports[`should render filled tabs 1`] = `
612616
style="--pf-v6-c-tabs--link-accent--length: 0px; --pf-v6-c-tabs--link-accent--start: 0px;"
613617
>
614618
<ul
619+
aria-label="Tab List"
615620
class="pf-v6-c-tabs__list"
616621
role="tablist"
617622
>
@@ -729,6 +734,7 @@ exports[`should render simple tabs 1`] = `
729734
style="--pf-v6-c-tabs--link-accent--length: 0px; --pf-v6-c-tabs--link-accent--start: 0px;"
730735
>
731736
<ul
737+
aria-label="Tab List"
732738
class="pf-v6-c-tabs__list"
733739
role="tablist"
734740
>
@@ -888,6 +894,7 @@ exports[`should render subtabs 1`] = `
888894
style="--pf-v6-c-tabs--link-accent--length: 0px; --pf-v6-c-tabs--link-accent--start: 0px;"
889895
>
890896
<ul
897+
aria-label="Tab List"
891898
class="pf-v6-c-tabs__list"
892899
role="tablist"
893900
>
@@ -974,6 +981,7 @@ exports[`should render subtabs 1`] = `
974981
style="--pf-v6-c-tabs--link-accent--length: 0; --pf-v6-c-tabs--link-accent--start: 0;"
975982
>
976983
<ul
984+
aria-label="Tab List"
977985
class="pf-v6-c-tabs__list"
978986
role="tablist"
979987
>
@@ -1117,6 +1125,7 @@ exports[`should render tabs with eventKey Strings 1`] = `
11171125
style="--pf-v6-c-tabs--link-accent--length: 0; --pf-v6-c-tabs--link-accent--start: 0;"
11181126
>
11191127
<ul
1128+
aria-label="Tab List"
11201129
class="pf-v6-c-tabs__list"
11211130
role="tablist"
11221131
>
@@ -1235,6 +1244,7 @@ exports[`should render tabs with no bottom border 1`] = `
12351244
style="--pf-v6-c-tabs--link-accent--length: 0px; --pf-v6-c-tabs--link-accent--start: 0px;"
12361245
>
12371246
<ul
1247+
aria-label="Tab List"
12381248
class="pf-v6-c-tabs__list"
12391249
role="tablist"
12401250
>
@@ -1352,6 +1362,7 @@ exports[`should render tabs with separate content 1`] = `
13521362
style="--pf-v6-c-tabs--link-accent--length: 0px; --pf-v6-c-tabs--link-accent--start: 0px;"
13531363
>
13541364
<ul
1365+
aria-label="Tab List"
13551366
class="pf-v6-c-tabs__list"
13561367
role="tablist"
13571368
>
@@ -1478,6 +1489,7 @@ exports[`should render uncontrolled tabs 1`] = `
14781489
style="--pf-v6-c-tabs--link-accent--length: 0px; --pf-v6-c-tabs--link-accent--start: 0px;"
14791490
>
14801491
<ul
1492+
aria-label="Tab List"
14811493
class="pf-v6-c-tabs__list"
14821494
role="tablist"
14831495
>
@@ -1637,6 +1649,7 @@ exports[`should render vertical tabs 1`] = `
16371649
style="--pf-v6-c-tabs--link-accent--length: 0px; --pf-v6-c-tabs--link-accent--start: 0px;"
16381650
>
16391651
<ul
1652+
aria-label="Tab List"
16401653
class="pf-v6-c-tabs__list"
16411654
role="tablist"
16421655
>

0 commit comments

Comments
 (0)