Skip to content

Commit

Permalink
feat(tabs): traverse tabs with arrow keys (#8116)
Browse files Browse the repository at this point in the history
  • Loading branch information
weronikaolejniczak authored Nov 21, 2024
1 parent 9b1b461 commit df7a98f
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/eui/changelogs/upcoming/8116.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**Accessibility**

- Improved the accessibility experience of tabs (EuiTab, EuiTabs): tab group is a tab stop and tabs can be traversed with arrow keys.

Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ exports[`EuiPageHeader props page content props are passed down is rendered 1`]
aria-selected="true"
class="euiTab euiTab-isSelected emotion-euiTab-selected"
role="tab"
tabindex="0"
type="button"
>
<span
Expand All @@ -354,6 +355,7 @@ exports[`EuiPageHeader props page content props are passed down is rendered 1`]
aria-selected="false"
class="euiTab emotion-euiTab"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ exports[`EuiPageHeaderContent props children is rendered even if content props a
aria-selected="true"
class="euiTab euiTab-isSelected emotion-euiTab-selected"
role="tab"
tabindex="0"
type="button"
>
<span
Expand All @@ -312,6 +313,7 @@ exports[`EuiPageHeaderContent props children is rendered even if content props a
aria-selected="false"
class="euiTab emotion-euiTab"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -557,6 +559,7 @@ exports[`EuiPageHeaderContent props tabs is rendered 1`] = `
aria-selected="true"
class="euiTab euiTab-isSelected emotion-euiTab-selected"
role="tab"
tabindex="0"
type="button"
>
<span
Expand All @@ -569,6 +572,7 @@ exports[`EuiPageHeaderContent props tabs is rendered 1`] = `
aria-selected="false"
class="euiTab emotion-euiTab"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -608,6 +612,7 @@ exports[`EuiPageHeaderContent props tabs is rendered with tabsProps 1`] = `
aria-selected="true"
class="euiTab euiTab-isSelected emotion-euiTab-selected"
role="tab"
tabindex="0"
type="button"
>
<span
Expand All @@ -620,6 +625,7 @@ exports[`EuiPageHeaderContent props tabs is rendered with tabsProps 1`] = `
aria-selected="false"
class="euiTab emotion-euiTab"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`EuiTab props append is rendered 1`] = `
aria-selected="false"
class="euiTab emotion-euiTab"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand All @@ -26,6 +27,7 @@ exports[`EuiTab props disabled and selected 1`] = `
class="euiTab euiTab-isSelected emotion-euiTab-disabled-selected"
disabled=""
role="tab"
tabindex="0"
type="button"
>
<span
Expand All @@ -42,6 +44,7 @@ exports[`EuiTab props disabled is rendered 1`] = `
class="euiTab emotion-euiTab-disabled"
disabled=""
role="tab"
tabindex="-1"
type="button"
>
<span
Expand All @@ -61,6 +64,7 @@ exports[`EuiTab props href renders anchor 1`] = `
href="/baz/bing"
rel="noreferrer"
role="tab"
tabindex="-1"
>
<span
class="euiTab__content eui-textTruncate emotion-euiTab__content-m"
Expand All @@ -75,6 +79,7 @@ exports[`EuiTab props isSelected is rendered 1`] = `
aria-selected="true"
class="euiTab euiTab-isSelected emotion-euiTab-selected"
role="tab"
tabindex="0"
type="button"
>
<span
Expand All @@ -92,6 +97,7 @@ exports[`EuiTab props onClick renders button 1`] = `
class="euiTab testClass1 testClass2 emotion-euiTab-euiTestCss"
data-test-subj="test subject string"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand All @@ -107,6 +113,7 @@ exports[`EuiTab props prepend is rendered 1`] = `
aria-selected="false"
class="euiTab emotion-euiTab"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`EuiTabs props expand passes down to EuiTab children 1`] = `
aria-selected="false"
class="euiTab emotion-euiTab-expanded"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand All @@ -29,6 +30,7 @@ exports[`EuiTabs props size l renders and passes down to EuiTab children 1`] = `
aria-selected="false"
class="euiTab emotion-euiTab"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand All @@ -49,6 +51,7 @@ exports[`EuiTabs props size m renders and passes down to EuiTab children 1`] = `
aria-selected="false"
class="euiTab emotion-euiTab"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand All @@ -69,6 +72,7 @@ exports[`EuiTabs props size s renders and passes down to EuiTab children 1`] = `
aria-selected="false"
class="euiTab emotion-euiTab"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand All @@ -89,6 +93,7 @@ exports[`EuiTabs props size xl renders and passes down to EuiTab children 1`] =
aria-selected="false"
class="euiTab emotion-euiTab"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand Down
2 changes: 2 additions & 0 deletions packages/eui/src/components/tabs/tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const EuiTab: FunctionComponent<Props> = ({
<a
role="tab"
aria-selected={!!isSelected}
tabIndex={isSelected ? 0 : -1}
className={classes}
css={cssTabStyles}
href={href}
Expand All @@ -123,6 +124,7 @@ export const EuiTab: FunctionComponent<Props> = ({
<button
role="tab"
aria-selected={!!isSelected}
tabIndex={isSelected ? 0 : -1}
type="button"
className={classes}
css={cssTabStyles}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports[`EuiTabbedContent is rendered with required props and tabs 1`] = `
class="euiTab euiTab-isSelected emotion-euiTab-selected"
id="es"
role="tab"
tabindex="0"
type="button"
>
<span
Expand All @@ -31,6 +32,7 @@ exports[`EuiTabbedContent is rendered with required props and tabs 1`] = `
data-test-subj="kibanaTab"
id="kibana"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -76,6 +78,7 @@ exports[`EuiTabbedContent props autoFocus initial is rendered 1`] = `
class="euiTab euiTab-isSelected emotion-euiTab-selected"
id="es"
role="tab"
tabindex="0"
type="button"
>
<span
Expand All @@ -91,6 +94,7 @@ exports[`EuiTabbedContent props autoFocus initial is rendered 1`] = `
data-test-subj="kibanaTab"
id="kibana"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -136,6 +140,7 @@ exports[`EuiTabbedContent props autoFocus selected is rendered 1`] = `
class="euiTab euiTab-isSelected emotion-euiTab-selected"
id="es"
role="tab"
tabindex="0"
type="button"
>
<span
Expand All @@ -151,6 +156,7 @@ exports[`EuiTabbedContent props autoFocus selected is rendered 1`] = `
data-test-subj="kibanaTab"
id="kibana"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -196,6 +202,7 @@ exports[`EuiTabbedContent props initialSelectedTab renders a selected tab 1`] =
class="euiTab emotion-euiTab"
id="es"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand All @@ -211,6 +218,7 @@ exports[`EuiTabbedContent props initialSelectedTab renders a selected tab 1`] =
data-test-subj="kibanaTab"
id="kibana"
role="tab"
tabindex="0"
type="button"
>
<span
Expand Down Expand Up @@ -256,6 +264,7 @@ exports[`EuiTabbedContent props selectedTab renders a selected tab 1`] = `
class="euiTab emotion-euiTab"
id="es"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand All @@ -271,6 +280,7 @@ exports[`EuiTabbedContent props selectedTab renders a selected tab 1`] = `
data-test-subj="kibanaTab"
id="kibana"
role="tab"
tabindex="0"
type="button"
>
<span
Expand Down Expand Up @@ -316,6 +326,7 @@ exports[`EuiTabbedContent props size can be small 1`] = `
class="euiTab euiTab-isSelected emotion-euiTab-selected"
id="es"
role="tab"
tabindex="0"
type="button"
>
<span
Expand All @@ -331,6 +342,7 @@ exports[`EuiTabbedContent props size can be small 1`] = `
data-test-subj="kibanaTab"
id="kibana"
role="tab"
tabindex="-1"
type="button"
>
<span
Expand Down
Loading

0 comments on commit df7a98f

Please sign in to comment.