Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tablist): make aria-label optional #18323

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7837,7 +7837,6 @@ Map {
"type": "oneOf",
},
"aria-label": Object {
"isRequired": true,
"type": "string",
},
"children": Object {
Expand Down
26 changes: 13 additions & 13 deletions packages/react/src/components/Tabs/Tabs.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default {

export const Default = ({ dismissable, ...args }) => (
<Tabs dismissable={dismissable} onTabCloseRequest={() => {}}>
<TabList aria-label="List of tabs" {...args}>
<TabList {...args}>
<Tab>Dashboard</Tab>
<Tab>Monitoring</Tab>
<Tab>Activity</Tab>
Expand Down Expand Up @@ -186,7 +186,7 @@ export const Dismissable = () => {
onChange={handleTabChange}
dismissable
onTabCloseRequest={handleCloseTabRequest}>
<TabList aria-label="List of tabs">
<TabList>
{renderedTabs.map((tab, index) => (
<Tab key={index} disabled={tab.disabled}>
{tab.label}
Expand Down Expand Up @@ -259,7 +259,7 @@ export const DismissableWithIcons = ({ contained }) => {
onChange={handleTabChange}
dismissable
onTabCloseRequest={handleCloseTabRequest}>
<TabList aria-label="List of tabs" contained={contained}>
<TabList contained={contained}>
{renderedTabs.map((tab, index) => (
<Tab key={index} disabled={tab.disabled} renderIcon={icons[index]}>
{tab.label}
Expand All @@ -274,7 +274,7 @@ export const DismissableWithIcons = ({ contained }) => {

export const WithIcons = () => (
<Tabs>
<TabList activation="manual" aria-label="List of tabs">
<TabList activation="manual">
<Tab renderIcon={Dashboard}>Dashboard</Tab>
<Tab renderIcon={CloudMonitoring}>Monitoring</Tab>
<Tab renderIcon={Activity}>Activity</Tab>
Expand Down Expand Up @@ -311,7 +311,7 @@ export const WithIcons = () => (

export const Manual = () => (
<Tabs>
<TabList activation="manual" aria-label="List of tabs">
<TabList activation="manual">
<Tab>Dashboard</Tab>
<Tab>Monitoring</Tab>
<Tab title="Tab label 4">Activity</Tab>
Expand Down Expand Up @@ -346,7 +346,7 @@ export const Manual = () => (

export const Icon20Only = () => (
<Tabs>
<TabList iconSize="lg" aria-label="List of tabs">
<TabList iconSize="lg">
<IconTab label="Analyze" disabled>
<Search size={20} aria-label="Analyze" />
</IconTab>
Expand All @@ -371,7 +371,7 @@ export const Icon20Only = () => (

export const IconOnly = () => (
<Tabs>
<TabList aria-label="List of tabs">
<TabList>
<IconTab label="Analyze" disabled>
<Search aria-label="Analyze" />
</IconTab>
Expand All @@ -396,7 +396,7 @@ export const IconOnly = () => (

export const Contained = () => (
<Tabs>
<TabList aria-label="List of tabs" contained>
<TabList contained>
<Tab>Dashboard</Tab>
<Tab>Monitoring</Tab>
<Tab>Activity</Tab>
Expand Down Expand Up @@ -432,7 +432,7 @@ export const Contained = () => (

export const ContainedWithIcons = () => (
<Tabs>
<TabList aria-label="List of tabs" contained>
<TabList contained>
<Tab renderIcon={Dashboard}>Dashboard</Tab>
<Tab renderIcon={CloudMonitoring}>Monitoring</Tab>
<Tab renderIcon={Activity}>Activity</Tab>
Expand Down Expand Up @@ -470,7 +470,7 @@ export const ContainedWithIcons = () => (

export const ContainedWithSecondaryLabels = () => (
<Tabs>
<TabList aria-label="List of tabs" contained>
<TabList contained>
<Tab secondaryLabel="(21/25)">Engage</Tab>
<Tab secondaryLabel="(12/16)">Analyze</Tab>
<Tab secondaryLabel="(0/7)">Remediate</Tab>
Expand Down Expand Up @@ -508,7 +508,7 @@ export const ContainedWithSecondaryLabels = () => (

export const ContainedWithSecondaryLabelsAndIcons = () => (
<Tabs>
<TabList aria-label="List of tabs" contained>
<TabList contained>
<Tab renderIcon={Task} secondaryLabel="(21/25">
Engage
</Tab>
Expand Down Expand Up @@ -556,7 +556,7 @@ export const ContainedFullWidth = () => (
<Grid condensed>
<Column lg={16} md={8} sm={4}>
<Tabs>
<TabList aria-label="List of tabs" contained fullWidth>
<TabList contained fullWidth>
<Tab>TLS</Tab>
<Tab>Origin</Tab>
<Tab disabled>Rate limiting</Tab>
Expand Down Expand Up @@ -600,7 +600,7 @@ export const ContainedFullWidth = () => (

export const Vertical = ({ ...args }) => (
<TabsVertical {...args}>
<TabListVertical aria-label="List of tabs">
<TabListVertical>
<Tab>Dashboard</Tab>
<Tab>
Extra long label that will go two lines then truncate when it goes
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export interface TabListProps extends DivAttributes {
* Provide an accessible label to be read when a user interacts with this
* component
*/
'aria-label': string;
'aria-label'?: string;

/**
* Provide child elements to be rendered inside `ContentTabs`.
Expand Down Expand Up @@ -778,7 +778,7 @@ TabList.propTypes = {
* Provide an accessible label to be read when a user interacts with this
* component
*/
'aria-label': PropTypes.string.isRequired,
'aria-label': PropTypes.string,

/**
* Provide child elements to be rendered inside `ContentTabs`.
Expand Down
Loading