From db79838998714037dd3e8a60e73994ce4f87f0c6 Mon Sep 17 00:00:00 2001 From: Nate Bailey Date: Tue, 25 Oct 2016 19:27:36 -0700 Subject: [PATCH 1/2] First (untested) pass at adding aria state by customizable modifier --- src/WeekdayPicker.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/WeekdayPicker.js b/src/WeekdayPicker.js index 524d259..7e00955 100644 --- a/src/WeekdayPicker.js +++ b/src/WeekdayPicker.js @@ -17,6 +17,7 @@ class WeekdayPicker extends Component { tabIndex: PropTypes.number, modifiers: PropTypes.object, + ariaModifier: PropTypes.string, locale: PropTypes.string, localeUtils: PropTypes.shape({ @@ -34,7 +35,8 @@ class WeekdayPicker extends Component { static defaultProps = { tabIndex: 0, locale: "en", - localeUtils: localeUtils + localeUtils: localeUtils, + ariaModifier: 'selected' } getModifiersForDay(d, modifierFunctions) { @@ -101,6 +103,8 @@ class WeekdayPicker extends Component { className += modifiers.map(modifier => ` ${className}--${modifier}`).join(""); + const ariaSelected = modifiers.indexOf(this.props.ariaModifier) > -1; + const { onWeekdayMouseEnter, onWeekdayMouseLeave, onWeekdayTouchTap, onWeekdayClick } = this.props; let tabIndex = null; @@ -122,6 +126,7 @@ class WeekdayPicker extends Component { (e) => this.handleWeekdayClick(e, weekday, modifiers) : null } onTouchTap= { onWeekdayTouchTap ? (e) => this.handleWeekdayTouchTap(e, weekday, modifiers) : null } + ariaSelected={ariaSelected} > { localeUtils.formatWeekdayShort(weekday, locale) } From 35b35d9a42db75133dce58f1e4cebb241baf76f6 Mon Sep 17 00:00:00 2001 From: Nate Bailey Date: Wed, 26 Oct 2016 13:39:54 -0700 Subject: [PATCH 2/2] React expects kebab-case (hah!) for aria attributes --- src/WeekdayPicker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WeekdayPicker.js b/src/WeekdayPicker.js index 7e00955..074c9e2 100644 --- a/src/WeekdayPicker.js +++ b/src/WeekdayPicker.js @@ -126,7 +126,7 @@ class WeekdayPicker extends Component { (e) => this.handleWeekdayClick(e, weekday, modifiers) : null } onTouchTap= { onWeekdayTouchTap ? (e) => this.handleWeekdayTouchTap(e, weekday, modifiers) : null } - ariaSelected={ariaSelected} + aria-selected={ariaSelected} > { localeUtils.formatWeekdayShort(weekday, locale) }