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

Tab to edit cell rendered with renderEditCell in row edit mode #9020

Closed
2 tasks done
theobrasseurbentley opened this issue May 17, 2023 · 3 comments
Closed
2 tasks done
Labels
component: data grid This is the name of the generic UI component, not the React module!

Comments

@theobrasseurbentley
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/mui-x-issue-template-forked-cqdinb?file=/src/App.tsx

Steps:

  1. Focus cell with value cell_1
  2. Press the tab key on the keyboard

Current behavior 😯

Focus remains on cell with value cell_1

Expected behavior 🤔

Focus moves to cell with value cell_2

Context 🔦

tab to the next cell in row edit mode

Your environment 🌎

npx @mui/envinfo

Browser: chrome

System:
    OS: Windows 10 10.0.19044
  Binaries:
    Node: 16.17.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.15.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 113.0.5672.126
    Edge: Spartan (44.19041.1266.0), Chromium (113.0.1774.42)
  npmPackages:
    @emotion/react:  11.10.6
    @emotion/styled:  11.10.6
    @mui/base:  5.0.0-alpha.96
    @mui/core-downloads-tracker:  5.12.2
    @mui/icons-material:  5.11.16
    @mui/lab: ^5.0.0-alpha.98 => 5.0.0-alpha.98
    @mui/material: ^5.10.15 => 5.12.2
    @mui/private-theming:  5.12.0
    @mui/styled-engine:  5.12.0
    @mui/system:  5.12.1
    @mui/types:  7.2.4
    @mui/utils:  5.12.0
    @mui/x-data-grid:  6.3.0
    @mui/x-data-grid-premium: ^6.3.0 => 6.3.0
    @mui/x-data-grid-pro:  6.3.0
    @mui/x-date-pickers:  5.0.20
    @mui/x-license-pro: ^6.0.0-beta.3 => 6.0.4
    @types/react: ^18.0.21 => 18.2.0
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.2 => 17.0.2
    typescript: ^4.8.4 => 4.9.5

Order ID or Support key 💳 (optional)

59960

@theobrasseurbentley theobrasseurbentley added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 17, 2023
@m4theushw
Copy link
Member

I didn't understand correctly what is expected. If the cell is in view mode and I press Tab the focus is moved to the next focusable element. In the case of the demo provided it goes to body. If the row is in edit mode, then Tab goes to the next input element, because it's also the next focusable element. Note that we implement https://www.w3.org/WAI/ARIA/apg/patterns/grid/ and the Tab key is not used for cell navigation. See https://mui.com/x/react-data-grid/accessibility/#tab-sequence for more information.

@m4theushw m4theushw added component: data grid This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 17, 2023
@theobrasseurbentley
Copy link
Author

theobrasseurbentley commented May 18, 2023

Thank you for your answer
The example is missing a renderEditCell sorry. I added it to the live example.
Notice how in edit mode, focus does not move from cell with value cell_1 to cell with value cell_2 when pressing tab.
I expect it does.

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label May 18, 2023
@theobrasseurbentley theobrasseurbentley changed the title Tab to edit cell with TextField in row edit mode Tab to edit cell rendered with renderEditCell in row edit mode May 22, 2023
@m4theushw
Copy link
Member

When Tab is pressed and the currently focused cell is not the last one in the row we disable the default focus and delegate to the edit component to focus the appropriate element. We do this by passing hasFocus=true to the edit component. Here's one example from the bult-in edit component of the string column.

useEnhancedEffect(() => {
if (hasFocus) {
inputRef.current!.focus();
}
}, [hasFocus]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

2 participants