Skip to content

Commit

Permalink
Adding aria labels to nav buttons (Hacker0x01#1993)
Browse files Browse the repository at this point in the history
  • Loading branch information
klinskyc authored and martijnrusschen committed Jan 6, 2020
1 parent bb82068 commit d984798
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,17 @@ export default class Calendar extends React.Component {
classes.push("react-datepicker__navigation--previous--disabled");
clickHandler = null;
}

const isForYear = this.props.showMonthYearPicker || this.props.showQuarterYearPicker;

return (
<button
type="button"
className={classes.join(" ")}
onClick={clickHandler}
aria-label={isForYear ? "Previous Year" : "Previous Month"}
>
{this.props.showMonthYearPicker || this.props.showQuarterYearPicker
{isForYear
? this.props.previousYearButtonLabel
: this.props.previousMonthButtonLabel}
</button>
Expand Down Expand Up @@ -441,14 +444,17 @@ export default class Calendar extends React.Component {
classes.push("react-datepicker__navigation--next--disabled");
clickHandler = null;
}


const isForYear = this.props.showMonthYearPicker || this.props.showQuarterYearPicker;

return (
<button
type="button"
className={classes.join(" ")}
onClick={clickHandler}
aria-label={isForYear ? "Next Year" : "Next Month"}
>
{this.props.showMonthYearPicker || this.props.showQuarterYearPicker
{ isForYear
? this.props.nextYearButtonLabel
: this.props.nextMonthButtonLabel}
</button>
Expand Down

0 comments on commit d984798

Please sign in to comment.