gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

react-datepicker is not accessible

Open afercia opened this issue 9 years ago • 51 comments

Looks like react-datepicker, currently used for the "publish" date, has several accessibility issues.

screen shot 2017-06-20 at 17 24 25

Just to mention a few:

  • not operable with a keyboard
  • empty and not focusable prev/next month links
  • day names not in relationship with the day numbers
  • arguable values for the day aria-labels, e.g. day-15
  • missing labels for the hour/minutes fields

I was also able to break it completely just editing the hour/mins fields using a keyboard:

screen shot 2017-06-15 at 14 51 02

I'd strongly recommend that every external component/library included in Gutenberg should be picked up taking into consideration also its accessibility support.

Not sure react-datepicker can be easily patched and made decently accessible. It would likely require a lot of work. Not sure if other, more accessible, react date-pickers exist. Not sure if using a date-picker is a good idea in the first place 🙁 Date pickers are always tricky.

One option could be considering a completely different UI, without a date-picker. Happy to evaluate other, more accessible, tools if any, but I'm afraid react-datepicker in its current state doesn't meet the quality standards we'd like to see in WordPress and it's a blocker for accessibility.

/cc @jasmussen and @joedolson (as he's an expert about calendars)

afercia avatar Jun 20 '17 15:06 afercia

Also to mention: AM/PM: not all countries in the world use them.

afercia avatar Jun 20 '17 15:06 afercia

AM/PM would definitely get a lot of pushback and require a localized UI for alternate date/time formats.

I don't have a great solution for datepickers - they are truly difficult to make predictable. One solution I've favored is to allow manual string entry of dates and times, so that the datepicker is an optional UI; but even as an optional UI I would need it to be accessible; I'd just be less concerned about the complexity of the interaction patterns from the keyboard.

joedolson avatar Jun 20 '17 16:06 joedolson

Is there any use of date pickers elsewhere in the admin (I've assumed not), or an audit of available solutions and their accessibility?

In another of my own projects, I've integrated Flatpickr with React successfully, and know it is at least keyboard operable and opens in response to receiving focus, but on a cursory glance lacks some labeling.

Another option is to create a homegrown solution built with accessibility in mind.

aduth avatar Jun 20 '17 16:06 aduth

I can't recall running across a datepicker anywhere. The jQuery datepicker is something that's in the set of scripts bundled with WordPress by default, but I'm not aware of a core usage of it. I'm not sure of the current state of accessibility in that script, but it wasn't satisfactory when I last assessed it. That was over 2 years ago, however.

I've used Pickadate myself, but it's lacking any stable project maintainer at the moment, so probably not viable.

Here's the only information I know about accessible date pickers.

joedolson avatar Jun 20 '17 16:06 joedolson

The jQuery UI datepicker was recently properly localized, see https://core.trac.wordpress.org/changeset/37908. RTL support is also a concern. I'm not aware of any core usage, best persons to ask to: @ocean90 and @swissspidy

afercia avatar Jun 20 '17 18:06 afercia

AM/PM: not all countries in the world use them.

It's only activated depending on the time format defined in the general settings

youknowriad avatar Jun 20 '17 18:06 youknowriad

The jQuery UI datepicker is currently not used in core. It‘s only localized for plugins using it.

swissspidy avatar Jun 20 '17 19:06 swissspidy

Related discussions on core Trac:

Add jQuery UI's datepicker() where applicable https://core.trac.wordpress.org/ticket/7665 (main discussion about jQuery UI's datepicker)

Use JS Calendar control for date picking https://core.trac.wordpress.org/ticket/11942 (closed as duplicate but helpful to understand why at that time jQuery UI was not used)

Edit published date of post - inputs with no labels https://core.trac.wordpress.org/ticket/25461 (more related to a11y)

Also to consider:

"Now" button for current date in update post published date and time https://core.trac.wordpress.org/ticket/14364

Publish Date DatePicker https://wordpress.org/plugins/publish-date-datepicker/ Plugin that adds the date picker to the UI

afercia avatar Jun 21 '17 07:06 afercia

Marking with the high priority label to indicate it's an a11y priority. At the very least, there should be an alternative way to enter a date using only a keyboard.

afercia avatar Aug 29 '17 14:08 afercia

Couple options to consider:

aduth avatar Aug 29 '17 16:08 aduth

The react-dates component maintained by Airbnb claims by its description to be accessible

Maybe it's accessible, but it's announcing me the wrong month and days 😬 Maybe it's just a configuration issue. Hopefully. Not the best start, though.

screen shot 2017-09-06 at 17 33 10

I've run just a very quick, preliminar, test. I've navigated to a previous month (also, notice the color contrast on previous months is far from being accessible) but the wrong month/days are announced also on the initial view:

screen shot 2017-09-06 at 17 41 23

afercia avatar Sep 06 '17 15:09 afercia

@afercia I'm curious if either if these datepickers would qualify as accessible:

  • Whatsock Date Picker (link)
  • Medium.com's date picker (the input field appears to be accessible, but the dropdown calendar is not) (screenshot)

jwold avatar Sep 06 '17 18:09 jwold

@jwold The latter of those two appears to be the browser-default <input type="date"> (specifically, Chrome's).

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date

aduth avatar Sep 06 '17 19:09 aduth

Sorry for the very late reply. The Whatsock Date Picker one, after an initial test, seems to work pretty well with keyboard and screen readers.

afercia avatar Nov 08 '17 18:11 afercia

Thanks for the followup! Glad to hear that about the Whatsock Data Picker.

jwold avatar Nov 08 '17 22:11 jwold

Even for those just using a mouse it's not clear how to actually get out of the date picker. What is the action that makes it disappear after successfully picking a date: Is it the date? No. Is it the time? No. Is it the pm/am? No.

The only action that makes the date picker disappear and let's me continue with my work, is clicking outside the datepicker.

bph avatar Mar 26 '18 15:03 bph

+1 for the idea of not forcing people to use a date picker. Even if it were possible to find one that is accessible, it's a bit of an overhead for sighted keyboard users, and screen reader users.

Can we not use something similar to the publish date in the existing edit pages - a dropdown, plus text boxes, or something similar. Interacting with that would be a lot easier.

grahamarmfield avatar Apr 13 '18 15:04 grahamarmfield

a dropdown, plus text boxes, or something similar. Interacting with that would be a lot easier.

This may be subjective. I've personally found the classic editor's date inputs to be cumbersome to use contrasted with other date pickers I've used (web or otherwise).

aduth avatar Apr 13 '18 15:04 aduth

How about making it an either/or option? So that people can use a date picker if they want to, but don't have to.

grahamarmfield avatar Apr 13 '18 15:04 grahamarmfield

How about making it an either/or option? So that people can use a date picker if they want to, but don't have to.

Seems to fall against the "Decisions, not Options" mantra.

It hasn't been raised but not addressed as of yet: How does <input type="date"> fare for accessibility and usability? That it's browser-dependent is a bit concerning, though it is native. We'd still need a separate field for time.

aduth avatar Apr 13 '18 18:04 aduth