-
-
Notifications
You must be signed in to change notification settings - Fork 515
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
Implement WAI ARIA recommended focus handling #449
Conversation
35f9c0a
to
e848145
Compare
src/Calendar/Navigation.jsx
Outdated
// Make sure the navigation is not navigable at the first render | ||
// so that the calendar takes the initial focus. | ||
const [tabIndex, setTabIndex] = React.useState(-1); | ||
React.useEffect(() => { | ||
setTabIndex(-1); | ||
setTimeout(() => setTabIndex(0), 0); | ||
}, [view]); |
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.
That's a breaking change - we're currently requiring React 16.3 and up. Not saying this is a bad thing, just noting this to self.
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.
Ah right. Well, you could make that call I guess, in the similar spirit as not supporting older browsers.
@wojtekmaj so, WDYT? Is this an acceptable path forward? |
Yes, absolutely! We will need to wait for the next major release with this though, unfortunately. |
You may have already addressed it, but I could see an argument made for still being able to focus a disabled element. W3 guidance around disabled elements within a listbox, for instance support focusing on disabled elements, as otherwise, a non-sighted user would not be aware of them. Granted, grids, are not clear on if a cell is disabled, how that would effect keyboard navigation/focus - I could see an argument made here. |
Hello, do you have an approximate time for releasing this feature? Would be glad to have some information about it :) |
This change is breaking compatibility with older versions of React so this will need to be merged after the next major, dropping support for React <16.8 is released. |
Is there any info on when this might be released? This is quite an important feature for us. |
This focus handling implementation won't work when rendering multiple months: We don't want the calendar component to automatically shift Doing this multiple months feature is pretty easy with current export function MonthlyCalendar(props: Props) {
const { formatDate } = useIntl();
// date-fns
const months = eachMonthOfInterval({ start: props.minDate, end: props.maxDate });
return (
<>
{months.map((startOfMonth) => (
<Wrapper key={startOfMonth.toISOString()}>
<Title>
<FormattedDate value={startOfMonth} month="long" year="numeric" />
</Title>
<Calendar
{...props}
activeStartDate={startOfMonth}
maxDetail="month"
showNavigation={false}
showNeighboringMonth={false}
formatLongDate={(_locale, date) => formatDate(date, dayOptions)}
/>
</Wrapper>
))}
</>
);
} It might be that this kind of rendering has to be supported by Update Decided to do a full-custom implementation to make sure things work nice from a11y standpoint. |
523cf83
to
290738e
Compare
12b3d6b
to
398685c
Compare
can we bring this back now that 4.0.0 is out with react 16.8+ |
We most definitely can! |
14343f4
to
90f76b6
Compare
90f76b6
to
252c596
Compare
Some issues I have noticed:
|
Unfortunately I won't find time to work on this any time soon :( |
I'd love to help get this over the finish line, as it seems pretty close. Thanks for the great start @pekala. I fixed the issue with the page scrolling on arrow usage, and made a couple other UX improvements.
Thanks! |
I ended up creating a new PR - figuring they will reference each other, so none of the history in this thread will be lost. |
Fixes #354
Introduces the concept of an active focusable element, to adjust the keyboard interaction to match WAI-ARIA recommendations.
@wojtekmaj Would love your help in pushing this out. Things I don't handle yet (that I know of):