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

Combine labelled DayPicker container elements #1783

Merged
merged 1 commit into from
Sep 17, 2019

Conversation

ahuth
Copy link
Contributor

@ahuth ahuth commented Sep 16, 2019

This is to fix an issue where TalkBack (screen reader for Android devices) reads out all of the content of the calendar when focused. Every single day gets read out.

What I think is happening is:

  • There are two wrapping divs. The outer has accessibility labels, while the inner has tabindex. Something like:

    <div aria-label={phrases.calendarLabel}>
      <!-- More elements -->
      <div tabindex="-1">
        <!-- All the calendar content -->
      </div>
    </div>
  • TalkBack is focusing on the inner wrapping div (with the tab index). Since there's no label or title, it reads out the content. Which happens to be the dates.

  • VoiceOver on iOS can't focus on wrapping divs that have children with content, however. And we don't see the issue there.

  • VoiceOver on MacOS seems to read the aria-label, and skips the div with tab index and no label.

I investigated a couple potential solutions to this:

  1. Add an aria-label to the inner wrapping div

    Decided not to do this, because it results in two wrapping containers that TalkBack on Android and VoiceOver on MacOS focus on, before getting to the calendar controls. ❌

  2. Remove tabIndex={-1} from the inner wrapping div

    Decided not to do this, because there's some logic around focusing on it when the isFocused prop becomes true. Haven't found another div that makes sense to focus in that case that don't run into the same problem ❌

  3. Move the accessibility labeling from the outer to the inner wrapping div

    This is what I've implemented here. Behavior appears to be unchanged on VoiceOver on iOS (doesn't focus on the wrapping divs at all), VoiceOver on MacOS (focuses first on the labelled wrapping div). On TalkBack it reads out the label, instead of all the calendar content. ✅

    Unfortunately there's a downside. When reading the label, TalkBack now reads out something like "Calendar. Double click to activate", even though there's nothing to activate. Double clicking at that level literally does nothing. ❌

@majapw @backwardok do you have any ideas on other ways of fixing this?

This is to fix an issue [1] where TalkBack (the screen reader for Android devices) reads out the entire contents of the calendar when focused. This includes every single day in the displayed calendar, which is super painful for users using TalkBack.

What's happening is that there is a wrapping div with a tabindex of -1 and no label or title that the screen reader can read. Because there's no label, TalkBack reads out its content, which happens to be all of the calendar days. VoiceOver on iOS doesn't have this problem because it can't (currently) focus on div containers that have children with content.

To fix, I've moved the current accessibility labelling, which was on a wrapping div higher up the DOM tree, onto the "focusable" wrapping div. VoiceOver on iOS still won't focus on and read it, but TalkBack on Android will read it correctly.

There is one downside to this, however. When Talkback reads out the labe, it ends with "double tap to activate". That doesn't do anything, though.

1. https://jira.airbnb.biz/browse/PRODUCT-94500
@coveralls
Copy link

Coverage Status

Coverage remained the same at 85.005% when pulling e6ced9d on ah-fix-a11y-issue-with-talkback into c588a9d on master.

@ljharb ljharb added the accessibility Anything related to ensuring *everybody* can use react-dates <3 label Sep 16, 2019
@ahuth
Copy link
Contributor Author

ahuth commented Sep 17, 2019

Thanks!

@ahuth ahuth merged commit 0c5264f into master Sep 17, 2019
@ahuth ahuth deleted the ah-fix-a11y-issue-with-talkback branch September 17, 2019 20:50
@ahuth ahuth mentioned this pull request Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Anything related to ensuring *everybody* can use react-dates <3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants