Skip to content

Commit

Permalink
fix(Tabs): add aria-label to overflow scroll buttons (#7353)
Browse files Browse the repository at this point in the history
* fix(Tabs): add aria-label to overflow scroll buttons

* feat(Tabs): support additional overflow button props

* chore: update snapshots

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
emyarod and kodiakhq[bot] authored Jan 19, 2021
1 parent a7d0aa7 commit 07e3e1d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5098,6 +5098,9 @@ Map {
"hidden": Object {
"type": "bool",
},
"leftOverflowButtonProps": Object {
"type": "object",
},
"light": Object {
"type": "bool",
},
Expand All @@ -5110,6 +5113,9 @@ Map {
"onSelectionChange": Object {
"type": "func",
},
"rightOverflowButtonProps": Object {
"type": "object",
},
"scrollIntoView": Object {
"type": "bool",
},
Expand Down
20 changes: 18 additions & 2 deletions packages/react/src/components/Tabs/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export default class Tabs extends React.Component {
*/
hidden: PropTypes.bool,

/**
* Provide the props that describe the left overflow button
*/
leftOverflowButtonProps: PropTypes.object,

/**
* Specify whether or not to use the light component variant
*/
Expand All @@ -59,6 +64,11 @@ export default class Tabs extends React.Component {
*/
onSelectionChange: PropTypes.func,

/**
* Provide the props that describe the right overflow button
*/
rightOverflowButtonProps: PropTypes.object,

/**
* Choose whether or not to automatically scroll to newly selected tabs
* on component rerender
Expand Down Expand Up @@ -389,6 +399,8 @@ export default class Tabs extends React.Component {
scrollIntoView, // eslint-disable-line no-unused-vars
selectionMode, // eslint-disable-line no-unused-vars
tabContentClassName,
leftOverflowButtonProps,
rightOverflowButtonProps,
...other
} = this.props;

Expand Down Expand Up @@ -479,6 +491,7 @@ export default class Tabs extends React.Component {
<div {...other} className={classes.tabs} onScroll={this.handleScroll}>
<button
aria-hidden="true"
aria-label="Scroll left"
className={classes.leftOverflowButtonClasses}
onClick={(_) => this.handleOverflowNavClick(_, { direction: -1 })}
onMouseDown={(event) =>
Expand All @@ -487,7 +500,8 @@ export default class Tabs extends React.Component {
onMouseUp={this.handleOverflowNavMouseUp}
ref={this.leftOverflowNavButton}
tabIndex="-1"
type="button">
type="button"
{...leftOverflowButtonProps}>
<ChevronLeft16 />
</button>
{!leftOverflowNavButtonHidden && (
Expand All @@ -505,6 +519,7 @@ export default class Tabs extends React.Component {
)}
<button
aria-hidden="true"
aria-label="Scroll right"
className={classes.rightOverflowButtonClasses}
onClick={(_) => this.handleOverflowNavClick(_, { direction: 1 })}
onMouseDown={(event) =>
Expand All @@ -513,7 +528,8 @@ export default class Tabs extends React.Component {
onMouseUp={this.handleOverflowNavMouseUp}
ref={this.rightOverflowNavButton}
tabIndex="-1"
type="button">
type="button"
{...rightOverflowButtonProps}>
<ChevronRight16 />
</button>
</div>
Expand Down

0 comments on commit 07e3e1d

Please sign in to comment.