-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
87331be
to
98bd035
Compare
src/components/CalendarMonth.jsx
Outdated
<table | ||
{...css(styles.CalendarMonth_table)} | ||
role="presentation" | ||
aria-labelledby={`CalendarMonth_caption__${toISOMonthString(month)}`} |
There was a problem hiding this comment.
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?
src/components/CalendarMonth.jsx
Outdated
<table | ||
{...css(styles.CalendarMonth_table)} | ||
role="presentation" | ||
aria-labelledby={`CalendarMonth_caption__${toISOMonthString(month)}`} |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
98bd035
to
ec8ac9e
Compare
PTAL @backwardok @gabergg |
There was a problem hiding this 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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I did!
@ljharb the reason for removing the 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 |
ec8ac9e
to
6c2e062
Compare
fc19881
to
aba5a55
Compare
@ljharb @backwardok @gabergg could I get a stamp on this? I think I've addressed concerns. |
There was a problem hiding this 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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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(); |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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! :)
aba5a55
to
2e7948d
Compare
2e7948d
to
9e76cc7
Compare
9e76cc7
to
ae1f8d9
Compare
ae1f8d9
to
4ae1487
Compare
There was a problem hiding this 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 😛
I blame jordan! :P |
I recently pulled in the latest version of
react-dates
into our internal repos and discovered a few accessibility issues through our automatic testing.aria-labelledby
attribute the table itself.to: @ljharb @gabergg @backwardok @airbnb/webinfra