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

[fields] Switch to next section when pressing Tab #9113

Open
2 tasks done
jameshulse opened this issue May 25, 2023 · 7 comments
Open
2 tasks done

[fields] Switch to next section when pressing Tab #9113

jameshulse opened this issue May 25, 2023 · 7 comments
Labels
component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature feature: Keyboard editing Related to the pickers keyboard edition

Comments

@jameshulse
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example: https://codesandbox.io/s/dawn-moon-3szlw1?file=/src/App.js

Steps:

  1. Click the month part of the Mui date picker
  2. Press the key

Current behavior 😯

Focus is moved away from the text field to the calendar icon?

Expected behavior 🤔

Focus should move from the 'month' part of the text field to the 'year' part. I would expect the same from <shift + tab> moving back.

Context 🔦

I am used to using my keyboard for navigation and this is the functionality I expect from a date picker as this is how the default browser picker works (at least in Chrome).

Your environment 🌎

npx @mui/envinfo

System:
OS: Linux 6.0 Pop!_OS 22.04 LTS
Binaries:
Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
Yarn: 1.22.15 - ~/.yarn/bin/yarn
npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
Browsers:
Chrome: 113.0
Firefox: 113.0
npmPackages:
@emotion/react: ^11.11.0 => 11.11.0
@emotion/styled: ^11.11.0 => 11.11.0
@mui/base: 5.0.0-alpha.128
@mui/core-downloads-tracker: 5.12.3
@mui/icons-material: ^5.11.16 => 5.11.16
@mui/material: ^5.12.3 => 5.12.3
@mui/private-theming: 5.12.3
@mui/styled-engine: 5.12.3
@mui/system: 5.12.3
@mui/types: 7.2.4
@mui/utils: 5.12.3
@mui/x-data-grid: 6.4.0
@mui/x-data-grid-pro: ^6.4.0 => 6.4.0
@mui/x-date-pickers: ^6.5.0 => 6.5.0
@mui/x-license-pro: 6.0.4
@types/react: 17.0.59
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
styled-components: ^4.4.1 => 4.4.1

Browser: Chromium Version 113.0.5672.92

Order ID or Support key 💳 (optional)

No response

@jameshulse jameshulse added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 25, 2023
@jameshulse jameshulse changed the title Pressing "tab" in DatePicker text field doesn't move between date parts [DatePicker] Pressing "tab" in DatePicker text field doesn't move between date parts May 25, 2023
@flaviendelangle
Copy link
Member

Cc @LukasTy

I initially implemented the navigation with Tab in #7797 but stalled the work due to some unanswered questions.

@flaviendelangle flaviendelangle added component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature feature: Keyboard editing Related to the pickers keyboard edition and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 25, 2023
@flaviendelangle flaviendelangle changed the title [DatePicker] Pressing "tab" in DatePicker text field doesn't move between date parts [fields] Switch to next section when pressing Tab May 25, 2023
@LukasTy
Copy link
Member

LukasTy commented May 25, 2023

Thank you for reporting this behavior discrepancy.
We are aware (#6384) of it and the current behavior is intentional.
The issue is that our current field components implementation lacks proper a11y support.
Making the Tab navigate between the sections of the field would only highlight the a11y shortcoming even more and might disorient certain screen reader users.

We have planned a refactor of the fields with better a11y support and in turn your expected keyboard navigation behavior for the next major. 😉

@jameshulse
Copy link
Author

jameshulse commented May 25, 2023

Okay, I will look forward to the next major version. Thanks.

Is it possible to extend our implementation to take advantage of the tab handler from #7797? We unfortunately won't be able to cater our whole application to screen readers at this stage, but could still make use of better keyboard support.

@flaviendelangle
Copy link
Member

Sure, here it is

It will not work in right to left, in order to fix it we would need to expose the internal information about the visual order in RTL or methods like selectNextSection / selectPreviousSection in fieldRef (which would be a nice higher-level information).

@LukasTy
Copy link
Member

LukasTy commented May 26, 2023

Sure, here it is

Just don't forget to move the event.preventDefault inside of each of the if blocks or refactor code to allow for regular tabulation to still work (tab out of the field). 👌

@flaviendelangle
Copy link
Member

Your right! I edited the demo 👍

@jameshulse
Copy link
Author

Fantastic. Thank you for taking the time @flaviendelangle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature feature: Keyboard editing Related to the pickers keyboard edition
Projects
None yet
Development

No branches or pull requests

3 participants