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 some apparent a11y issues with react-dates #780

Merged
merged 1 commit into from
Oct 23, 2017
Merged

Conversation

majapw
Copy link
Collaborator

@majapw majapw commented Oct 19, 2017

I recently pulled in the latest version of react-dates into our internal repos and discovered a few accessibility issues through our automatic testing.

  1. The caption id was not unique! Namely it was the same on each month which was causing some problems. It also was missing the corresponding aria-labelledby attribute the table itself.
  2. There was a text-contrast issue with the focus background color, so I modified the default styling to match what is currently used on airbnb.com. I still need to go back and make sure everything is customizable. :)
  3. I took the opportunity to address a lot of queries in the issues on this repo and make the input a real input.

to: @ljharb @gabergg @backwardok @airbnb/webinfra

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 86.738% when pulling 87331be on maja-fix-a11y-issues into a448352 on master.

@majapw majapw added the semver-major: breaking change A non-backwards-compatible change; anything that breaks code - including adding a peerDep. label Oct 19, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 86.738% when pulling 98bd035 on maja-fix-a11y-issues into a448352 on master.

<table
{...css(styles.CalendarMonth_table)}
role="presentation"
aria-labelledby={`CalendarMonth_caption__${toISOMonthString(month)}`}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe CalendarMonth_caption__${toISOMonthString(month)} in a var just to make sure they both get updated together?

<table
{...css(styles.CalendarMonth_table)}
role="presentation"
aria-labelledby={`CalendarMonth_caption__${toISOMonthString(month)}`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this has role="presentation", the label here doesn't mean as much (and also possibly won't even get read)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, does this belong in the DayPicker then? hmmm. But the DayPicker contains all the months, so perhaps it needs a different label?

Trying to follow up on https://github.com/airbnb/react-dates/pull/715/files#r139019568

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know that it's necessary, and I think even in general case, I don't know that the month name is as meaningful as a label outside of this table. I would imagine that the container for the picker may benefit from a label like "Date picker" or "Select a date", but the month is less valuable information for the higher level container

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just kill the id then

@majapw
Copy link
Collaborator Author

majapw commented Oct 20, 2017

PTAL @backwardok @gabergg

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 86.738% when pulling ec8ac9e on maja-fix-a11y-issues into a448352 on master.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on why the inputValue and startDateValue and endDateValue props aren't necessary?

@@ -43,7 +43,6 @@ const propTypes = forbidExtraProps({
onQuestionMark: PropTypes.func,

startDate: PropTypes.string,
startDateValue: PropTypes.string,
endDate: PropTypes.string,
endDateValue: PropTypes.string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean to remove this prop also?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I did!

@majapw
Copy link
Collaborator Author

majapw commented Oct 20, 2017

@ljharb the reason for removing the inputValue, startDateValue, and endDateValue props is that they were essentially a way to have the input element value to be in iso format even as the display format was something nicer. The effect was that a server-side submit of a form (rare, i know) would have a nice iso formatted date submitted.

Of course now that I have axed the concept of the fake input and real input (which is much better for accessibility reason), this is no longer necessary and the value of the input element is just the formatted date value when it exists.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 86.738% when pulling 6c2e062 on maja-fix-a11y-issues into a448352 on master.

@majapw majapw force-pushed the maja-fix-a11y-issues branch 2 times, most recently from fc19881 to aba5a55 Compare October 21, 2017 00:09
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 86.738% when pulling aba5a55 on maja-fix-a11y-issues into a448352 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 86.738% when pulling aba5a55 on maja-fix-a11y-issues into a448352 on master.

@majapw
Copy link
Collaborator Author

majapw commented Oct 21, 2017

@ljharb @backwardok @gabergg could I get a stamp on this? I think I've addressed concerns.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending one question

@@ -90,7 +88,6 @@ class DateInput extends React.Component {

if (focused && isFocused) {
this.inputRef.focus();
this.inputRef.select();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate in why the autoselection was removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo this is actually better for a11y. It's not expected that by default, moving to a text input will select everything in it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So before, when you focused on the input, it was select the whole text so that when you typed anything, it would just replace whatever was there. This seemed like a good approach when there was no cursor to indicate where you were in the input. However, with a cursor, it seems unnecessary behavior.

backwardok
backwardok previously approved these changes Oct 23, 2017
Copy link
Contributor

@backwardok backwardok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes lgtm, with one comment that can be addressed separately

@@ -90,7 +88,6 @@ class DateInput extends React.Component {

if (focused && isFocused) {
this.inputRef.focus();
this.inputRef.select();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo this is actually better for a11y. It's not expected that by default, moving to a text input will select everything in it.

@@ -181,6 +176,8 @@ class DateInput extends React.Component {
{...css(
styles.DateInput_input,
readOnly && styles.DateInput_input__readOnly,
focused && styles.DateInput_input__focused,
disabled && styles.DateInput_input__disabled,
)}
aria-label={placeholder}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably for another PR, but this shouldn't be set to placeholder. If a developer wanted to pass in whatever they set for the placeholder as both the label and the placeholder text (which I'd argue that they shouldn't), that should be an explicit decision and not a default one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's do that in a follow-up! :)

@coveralls
Copy link

Coverage Status

Coverage decreased (-82.3%) to 4.372% when pulling 2e7948d on maja-fix-a11y-issues into e2e5767 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 86.662% when pulling 9e76cc7 on maja-fix-a11y-issues into e2e5767 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 86.662% when pulling ae1f8d9 on maja-fix-a11y-issues into 6850c56 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 86.662% when pulling 4ae1487 on maja-fix-a11y-issues into 6850c56 on master.

Copy link
Contributor

@backwardok backwardok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github really doesn't want you to sneak changes past me apparently 😛

@majapw
Copy link
Collaborator Author

majapw commented Oct 23, 2017

I blame jordan! :P

@majapw majapw merged commit 1871b23 into master Oct 23, 2017
@majapw majapw deleted the maja-fix-a11y-issues branch October 23, 2017 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-major: breaking change A non-backwards-compatible change; anything that breaks code - including adding a peerDep.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants