Combine labelled DayPicker container elements #1783
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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:
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. ❌
Remove
tabIndex={-1}
from the inner wrapping divDecided 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 ❌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?