Comments (10)
Ah! Let me understand. Said the focus is on an element right before the widget, then:
- press
TAB
: focus the first day cell → pressRIGHT ARROW
: it focus the next day → pressENTER
orSPACEBAR
(eventually) fire theonClick
event → pressTAB
: focus the next focusable element (e.g. exit from the widget) - how should the navigation between months work, then? Now, using the arrow keys you can switch between the months when the widget is focused. if we remove
tabindex
from.DayPicker[role="widget"]
this won't work anymore (related: #41)
from react-day-picker.
press TAB: focus the first day cell → press RIGHT ARROW: it focus the next day → press ENTER or SPACEBAR (eventually) fire the onClick event → press TAB: focus the next focusable element (e.g. exit from the widget)
You are correct about the preferred behavior.
how should the navigation between months work, then? Now, using the arrow keys you can switch between the months when the widget is focused. if we remove tabindex from .DayPicker[role="widget"] this won't work anymore
I've likewise been ponder that. With react-widgets
Calendar widget, keying CONTROL + ARROW LEFT
or CONTROL + ARROW RIGHT
navigates between adjacent months, and focus moves to the same day on the new month. It makes sense to try to navigate to a similar place in different months to both retain orientation and potentially save key strokes. It is common and not unreasonable to require the use of the CONTROL
key. Behavior in the Calendar widget certainly gets interesting when navigating to months with different number of days:
- January 31 is in focus
- Key
CONTROL + RIGHT ARROW
- February 28 is in focus
- Key
CONTROL + RIGHT ARROW
- March 28 is in focus
If a day is outside of a range of a given month, it snaps to the closest day within the new range. To me, this seems reasonable, but this assumes that every day is focusable and that only one month is shown at a time.
We have two big issues to resolve that's a little more unique to the features of this widget:
- What happens when a group of months are shown? Does
CONTROL + ARROW LEFT|RIGHT
navigate the group or does it navigate each month within a group? What's the best behavior to accomplish both? The DHTML Style Guide date picker may be a good starting point to think about alternative keys, but it still assumes one month at a time. - How do the
.DayPicker-Day
states of focus and disabled (aria-disabled="true"
, #34) work in conjunction, and how does that relate to navigating among days, months, or month groups? It's not common for disabled interactive elements (or static elements) to receive focus. Therefore, navigating between focusable days should skip disabled days. By extension, how do you decide which new day receives focus on a month you're navigating to, when there could be no focusable day in that month? That gets really tricky, and I'm unsure what's sensible right now.
from react-day-picker.
I am starting to think that the current strategy for managing focus (i.e. managing focus among descendants, instead of using aria-activedescendant
) paired with removing focus on .DayPicker[role="widget"]
is a mistake, since this assumes that there will always be a .DayPicker-Day
with the ability to have focus. The [basic calendar example](http://www.gpbl.org/react-day-picker/#examples/Basic calendar) is already a counterargument to this approach. If there's no focusable .DayPicker-Day
, then there's no ability to control or even navigate to the widget.
Therefore, I now propose that aria-activedescendant
is the only sensible strategy moving forward. Leave focus on .DayPicker[role="widget"]
and if any descendant element is naturally interactive, then it should never receive focus (tabindex="-1"
). Add .DayPicker-Day--active
class modifier to visually align with the value of aria-activedescendant
. aria-activedescendant
should only refer to .DayPicker-Day
elements, not to other descendants.
from react-day-picker.
Hey @basham could you better explain how would the aria-activedescendant
strategy work? Would that just require to change the attribute, or the way the user interacts with the keyboard too?
from react-day-picker.
After a little more research on aria-activedescendant
, things will have to change a little more than I initial thought in #33.
Because we currently want only one active descendant per range of rendered months, aria-activedescendant
should be placed on some element encompassing all months. In our case, it should be .DayPicker
. However, aria-activedescendant
can't be paired with role="widget"
because that's too generic of a role type. The container's role must logically pair with the active descendant's role. A calendar with role="grid"
is absolutely best in paired with days of role="gridcell"
. Therefore, adjusting the original recommendation in #33:
- Add
role="grid"
to.DayPicker
, not to.DayPicker-Month
- Add
aria-readonly="true"
to.DayPicker
, not to.DayPicker-Month
- Add
aria-activedescendant
to.DayPicker
, not to.DayPicker-Month
- It's probably fine to leave
.DayPicker-Month
'saria-label
pointing to its respective.DayPicker-Caption
; I could see it alternatively pointing to.DayPicker-Body
, but that would need confirmation
In regard to getting aria-activedescendant
working:
- It's value should be an
id
of a.DayPicker-Day[role="gridcell"]
- If no
.DayPicker-Day
is active, then either remove the attribute altogether or make its value undefined (aria-activedescendant=""
) - When the active day changes via user interaction, then update the id value of
aria-activedescendant
to match; you should also be good to add other class modifiers elsewhere to reinforce what's happening (#44) - Because there could be multiple instances of this widget implemented, it may be best to dynamically generate and assign ids, such as using a hash
References
from react-day-picker.
Regarding keyboard behavior, this is a very excellent date picker demo, which should be used as an exemplar:
http://oaa-accessibility.org/example/15/
from react-day-picker.
Added #35 for the keyboard. I should organize better the code or is going to be difficult to test :)
from react-day-picker.
Added #51 for the keyboard. I should organize better the code or is going to be difficult to test :)
from react-day-picker.
@basham How can I use separate buttons for changing months in the daypicker
from react-day-picker.
@smithaitufe I'll follow up with you via email. We don't need to start an aside discussion on this GitHub issue.
from react-day-picker.
Related Issues (20)
- Bug: DayPicker does not automatically navigate to selected date
- Bug: Inline styles are not getting applied as intended, assistance needed please. HOT 1
- Bug: Lag when displaying many months and switching selected date HOT 1
- Bug: Dependency conflict with date-fns version 3.0.1 HOT 3
- Datepicker Allows Selection of Ranges with Disabled Days in Between HOT 1
- showOutsideDays is disabled 1st on month start always on Sunday HOT 1
- Hi! I'm not opening new issue because I think it can be somehow related with this one 🙂 HOT 3
- Disabled days can be selected with selected prop HOT 1
- Can't import the named export 'buildLocalizeFn' from non EcmaScript module (only default export is available)
- Accessibility issue in calendar picker in the latest version 8.10.0
- Empty inputField with useInput() is not behaving like unselect Date in DayPicker HOT 1
- Bug with label
- Calendar set's date to undefined when same date selected and this give inconsistent behavior! HOT 2
- Safari/iOS: hover background when unselecting a day HOT 3
- [Future Request] Enhancing changes to make React Day Picker responsive
- RootContext is missing pass-through types for each context it provides HOT 6
- toDate and fromDate are not working as expected
- inactive elements in the focus order - accessibility issue
- Improve Custom Components docs
- Select Week ➔ Week picker ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-day-picker.