Skip to content

Conversation

mahoneycm
Copy link
Contributor

@mahoneycm mahoneycm commented Jul 12, 2023

Summary

Improved keyboard navigation for screen readers. JAWS and NVDA no longer prevent default keyboard navigation behaviors when navigating with the left/right arrow keys.

As a minor improvement, this PR also updates button language to be more inclusive by removing "Click to" language!

Breaking change

This is not a breaking change.

Related issue

Resolves #4616

Related pull requests

Changelog →

Preview LInk

Date Picker →

Date Picker [DEVELOP] →

Problem statement

JAWS and NVDA prevent expected keyboard navigation within date picker calendar modals. In its current state, the up and down arrows navigate left and right, and using the left and right arrows spell out each letter of the selection.

Solution

By updating the wrapper date picker wrapper element to have the role of application, the expected keyboard behavior is possible while screen readers are opened.

Additionally, removing unnecessary roles from table elements allows screen reader users to navigate using table navigation controls defined by the screen reader (generally the screen reader's dedicated button + arrow keys).

Testing and review

  1. Visit the date picker component
  2. Activate screen readers available to you
  3. Navigate to calendar button using keyboard
  4. Activate the button using space or enter
  5. Navigate the calendar using arrow keys
  6. Navigate to next or previous month through date selection
  7. Select a date using space or enter

Testing Checklist

  • Date picker keyboard navigation with screen reader matches default keyboard navigation
    • Up and down arrow keys navigate up and down
    • Left and right arrow keys navigate left and right
  • Navigation between months is possible without leaving the calendar table
  • Screen reader callouts provide the necessary information to navigate without visual queues

Further considerations

Alternative solutions

This solution was based on the accessible screen reader offered by Deque University.

An alternative solution I demo'd was removing the table elements and using focusable spans & divs with role="application" on the wrapper element. This was based on a fix Carbon implemented in their date picker, and it's dynamic markup.

While testing with @amycole501, we found that while it did have great callouts and navigation from the screen reader, it did not highlight selected elements, which would be a new accessibility failure.

Draft PR for that change →

Possible downfalls

While the initial opening of the calendar works great for default keyboard navigation, tabbing into the month & year row and back into the calendar will require the user to use table navigation to navigate up and down. I believe this is because it is focusing the buttons within the TD's. This behavior exists in the Deque solution linked above as well.

The Month and Year grids are also only able to be navigated using left and right arrows at this time as well.

(Navigation above was with VoiceOver. Unsure of other screen reader behaviors after tabbing out of calendar grid at this time)


Before opening this PR, make sure you’ve done whichever of these applies to you:

  • Confirm that this code follows the 18F Front End Coding Style Guide and Accessibility Guide.
  • Run git pull origin [base branch] to pull in the most recent updates from your base and check for merge conflicts. (Often, the base branch is develop).
  • Run npm run prettier:js
  • Run npm test and confirm that all tests pass.

@mahoneycm mahoneycm changed the title USWDS- Date Picker: Update table rolls USWDS- Date Picker: Update table roles Jul 13, 2023
@mahoneycm mahoneycm marked this pull request as ready for review July 17, 2023 21:00
@mahoneycm mahoneycm marked this pull request as draft July 17, 2023 21:00
@mahoneycm mahoneycm changed the title USWDS- Date Picker: Update table roles USWDS- Date Picker: Improve date picker experience Jul 31, 2023
@mahoneycm mahoneycm changed the title USWDS- Date Picker: Improve date picker experience USWDS- Date Picker: Improve screen reader keyboard navigtation Jul 31, 2023
@mahoneycm mahoneycm marked this pull request as ready for review July 31, 2023 16:08
Copy link

@amycole501 amycole501 left a comment

Choose a reason for hiding this comment

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

This is a huge improvement in keyboard/arrow key functionality.

In JAWS I'm able to easily navigate to different dates using the up and down arrow keys. The screen reader announcements are clear and easy to follow.

The only issue in NVDA is that I hear "application: table" announced before it tells me what date/cell I'm on. The arrow keys work. It's just annoying to hear that after every single change in focus.

@mahoneycm
Copy link
Contributor Author

@amycole501 Thanks for your review!

Do you think that the NVDA "application: table" should hold back this change? Or do you think we should move forward with this improvement?

@amycole501
Copy link

The improvement is such that I think the minor announcement hiccup shouldn't hold up the change. The extra wording doesn't hinder usability so much as it makes it unnecessarily verbose. The important thing is that the person can use a keyboard to choose a date using the arrow keys. We can keep the "application table" issue in the backlog to fix in the future.

@mahoneycm
Copy link
Contributor Author

@amycole501 That's a great idea, I'll add an issue to the backlog. Would you mind Clicking the "Add Review" button at the top and leave a comment with the "Approved" radio button selected so github shows your approval?

image

image

Copy link

@amycole501 amycole501 left a comment

Choose a reason for hiding this comment

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

This is approved from an a11y standpoint because it's in much better shape using the keyboard/arrow keys. Minor issues with the NVDA announcement can be tackled in a separate ticket.

@amyleadem amyleadem changed the title USWDS- Date Picker: Improve screen reader keyboard navigtation USWDS- Date Picker: Improve screen reader keyboard navigation Aug 23, 2023
@amyleadem amyleadem self-assigned this Sep 6, 2023
Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

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

@mahoneycm, could you help me better understand what role="application" is doing here? I don't see any effect (positive or negative) in the VoiceOver experience. Is it necessary for JAWS and/or NVDA?

I tested with VoiceOver in Chrome, Safari, and Firefox. I also tested with VoiceOver Gestures in iOS Safari. I noticed only one minor VoiceOver regression from develop when using left/right swipe (See note about left and right swipe in touch interaction below).

I also saw some improvements, like being able to use table controls (VO + up/down arrow) to move up and down in Firefox, whereas up/down navigation was not possible before (See note about Up arrow/Down arrow below).

I did find a few gaps in the VoiceOver keyboard and touch experience. Most of these are likely out of scope on this issue, but I wanted to log these issues while I was testing in there to see if any of it makes sense to fix here. The items of concern are flagged in the list below. I figure we can make new issues from the description here if we don't want to tackle them now:

  • Screen reader readout matches develop

  • Screen reader readout is intuitive and make sense

    • Here is a visual of the readouts for each item. This example shows VoiceOver readout Chrome, but the other browsers provide similar readouts with just some small formatting differences. The readout seemed intuitive to me.

    image

    • ⚠️ It would probably be good to change the the “Click to select year” language to be more inclusive of other navigation methods.
  • Date picker keyboard navigation with screen reader is intuitive

    • Tab/Shift + Tab: Moves through navigation items above the calendar (Navigate back one year, navigate back one month, etc) then moves to the selected date.
    • Up arrow/Down arrow:
      • ⚠️ When VoiceOver is turned on in Chrome and Safari, the up and down arrows stop working as expected after using the Tab key anywhere in the component. (This matches the behavior in develop and also occurs in your div-based demo)
        • Note: This issue does NOT happen when using VO + Up/down arrow (This is an improvement over develop)
      • ⚠️ When VoiceOver is turned on in Firefox, the up and down arrows close the dialog when VoiceOver is turned on (This matches the behavior in develop and also occurs in your div-based demo)
        • Note: This issue does NOT happen when using VO + Up/down arrow (This is an improvement over develop)
    • Left arrow/Right arrow: Moves the date value forward or backward by one day.
    • Page up/Page down (Simulated in MacOS with Fn + Up arrow or Fn + Down arrow): Moves focus to the same date on the previous/next month
    • Enter when date is in focus : Adds the selected date to the input field
  • Date picker can be navigated easily with touch navigation

    • ⚠️ The initial readout provides keyboard instructions instead of touch instructions
    • Left and right swipe in iOS: Moves to the next/previous date
      • Behavior works as expected
      • ⚠️ Note: in iOS with VoiceOver gestures, the readout now includes the abbreviations for the day of the week before the date “Th - sept 28”, “Fr - sept 29”. It is not immediately clear what these letters mean (”Thursday” and “Friday”) and it would be better if they were not read out. (This issue does not happen in develop)
    • Up and down swipe in iOS with VO Gestures:
      • ⚠️ This does not work. Reads out “Heading not found” and does not move focus.
    • ⚠️ I could not discover an easy way to navigate into the top navigation bar (could only swipe left/right).
    • 💡 It would be great if the text input for date picker opened the number keypad. Right now it opens the standard alpha keypad.
  • Navigation between months is possible without leaving the calendar table

    • When VoiceOver is turned on in Chrome and Safari, using the up/down/left/right arrows will successfuly move to the previous/next month once focus is on the first/last of the month. (This matches the behavior in develop)
    • ⚠️ When VoiceOver is turned on in Firefox and VoiceOver Gestures is turned on in iOS Safari, you cannot move to another month with the left/right arrows. You must use the top navigation to move to next/previous month. (This matches the behavior in develop)

Update

I opened the following issues to address the pre-existing touch and keyboard interaction concerns:

@amyleadem amyleadem removed their assignment Sep 7, 2023
@amyleadem
Copy link
Contributor

Also, a small note but can you add more detail to the summary in the PR description?

@mahoneycm
Copy link
Contributor Author

More inclusive language

@amyleadem I like the idea of using this PR to update the "Click to" language to something more inclusive!

@amycole501 What do you think of Amy's comment?

It would probably be good to change the the “Click to select year” language to be more inclusive of other navigation methods.

Are you aware of better language we can use for actionable items?

@mahoneycm
Copy link
Contributor Author

Hey there @amyleadem ! Thanks for the detailed review!

role="application"

From mdn:

The application role indicates to assistive technologies that an element and all of its children should be treated similar to a desktop application, and no traditional HTML interpretation techniques should be used.

This solution was based on the accessible screen reader offered by Deque University as well as this fix implemented by the Carbon design system

My understanding is that this captures keyboard inputs better and allows us to define how the interactions should be handled, which we were already doing in the JS for the component.

The change was necessary for JAWS and NVDA to navigate the date picker components intuitively. Before, pressing left or right would read out the next character of the date string instead of moving to the next date. I adjusted the summary description to capture this better!

Inclusive language

I flagged Amy C in a separate comment to continue this discussion with less clutter 👍

Navigation after tabbing

I noticed the same behavior after using Tab and included this in my “Possible downfalls” section at the bottom of the PR.

This behavior is also present on the Deque University example I used as a reference for our solution.

Since the behavior exists on develop I didn’t want it to block the other improvements for JAWS and NVDA

Touch Navigation

This may be unintended side effects of using role="application" since it is not using the browser defaults to handle certain interactions.

Do you notice similar interactions on the Deque University example?

We might be able to resolve this by defining swipe behaviors similarly to how we’re defining keypresses

Alternatively, maybe we can apply the role based on the device? How do we feel about solutions like that?

Do you think that this should be a blocker for the PR? Or should we ticket this out in a new issue and continue there?

@amycole501
Copy link

@mahoneycm the easiest thing to do is just say "Select year" since everyone is selecting no matter the method. I found this resource helpful https://arthalearning.com/accessible-and-inclusive-language-in-elearning/

@amyleadem
Copy link
Contributor

Note
I opened the following issues to address the pre-existing touch and keyboard interaction concerns:

@mahoneycm
Copy link
Contributor Author

@amycole501 @amyleadem "Click to" language has been eradicated!

@mahoneycm mahoneycm requested a review from amyleadem September 14, 2023 19:15
Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

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

This is looking good on Safari/VoiceOver, @mahoneycm. There is one tiny regression in touch navigation but I think it is safe to move that to a follow-on issue. I’ve added details below.

  • No behavioral regressions from develop when navigating by keyboard in Safari/VoiceOver
    • One small improvement in keyboard navigation is the ability to navigate up and down in the calendar with VO + up/down arrow. In develop the up/down arrows caused various issues across browsers. (More details in [this comment])(#5374 (review))
  • No behavioral regressions from develop when navigating by touch in iOS Safari/VoiceOver Gestures
    • One small change with touch navigation readout in Safari/VoiceOver Gestures. Moving from one date to the next, the readout now includes the abbreviations for the day of the week before the date. For example,. “Th - sept 28”, “Fr - sept 29”. This adds a bit of confusion. I’ve opened to address touch navigation concerns: #5503
  • No visual regressions

Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

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

Nice work! I was able to navigate much better using voiceover keys. Previously, on develop, I could only move left/right on days.

One minor suggestion is to add a preview link to the current component on develop. That way we can open both quickly and compare.

@mejiaj mejiaj requested a review from thisisdano October 23, 2023 17:58
@mahoneycm
Copy link
Contributor Author

Link to Date Picker [DEVELOP] added to description!

Copy link
Contributor

@thisisdano thisisdano left a comment

Choose a reason for hiding this comment

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

Nice fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

USWDS - Bug: Date Picker keyboard navigation not working correctly with JAWS
5 participants