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

[DataGrid] Accessibility keyboard behaviour on a read-only selected cell doesn't take 'enter' to fire onCellClick. #2001

Closed
cbazza opened this issue Jun 30, 2021 · 5 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it

Comments

@cbazza
Copy link

cbazza commented Jun 30, 2021

When using keyboard navigation there is no way to have the same behaviour as clicking on the cell. I need Enter to fire onCellClick.

@cbazza cbazza added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 30, 2021
@oliviertassinari oliviertassinari changed the title <Enter> on keyboard navigation should fire onCellClick [DataGrid] Listen to keyboard events Jun 30, 2021
@oliviertassinari oliviertassinari changed the title [DataGrid] Listen to keyboard events [DataGrid] Listening to keyboard events Jun 30, 2021
@oliviertassinari oliviertassinari added 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 Jun 30, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 30, 2021

@cbazza We need more details. Could you expand on the problem you are trying to solve? Do you have a codesandbox or else to illustrate it?

Maybe you are looking for the GRID_CELL_EDIT_ENTER event instead that is triggers each time a cell goes into edit mode?

@cbazza
Copy link
Author

cbazza commented Jun 30, 2021

It's basically the accessibility behaviour when you tab and move the focus around with the keyboard.

Once it gets to the table, it highlights the first header and you can use the arrows to move the focus box around the table.
The problem is that when you press 'enter' on the focused cell it does nothing.
Material UI behaviour is to fire the onClick event.

Just the very basic table with no editable cells at all. Table has onCellClick setup so that once user clicks on cell is does the callback. All I want is that exact same behaviour if user uses keyboard to navigate to cell and press 'enter', it should call onCellClick.

@cbazza cbazza changed the title [DataGrid] Listening to keyboard events [DataGrid] Accessibility keyboard behaviour on a read-only selected cell doesn't take 'enter' to fire onCellClick. Jun 30, 2021
@oliviertassinari oliviertassinari added component: data grid This is the name of the generic UI component, not the React module! status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it and removed status: waiting for author Issue with insufficient information labels Jun 30, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 30, 2021

You can use GRID_CELL_KEY_DOWN to listen to the Enter on the cell. https://www.w3.org/TR/wai-aria-practices/#grid has no supporting material for the expected behavior. So I conclude that enter should not trigger a click event nor do any action on a regular cell's container. Thanks for raising the frustration.

@cbazza
Copy link
Author

cbazza commented Jul 1, 2021

From the documentation it doesn't look like DataGrid takes an apiRef prop like XGrid.
https://material-ui.com/components/data-grid/events/
https://material-ui.com/api/data-grid/x-grid/
https://material-ui.com/api/data-grid/data-grid/
So I don't see how to get access to these events.
Maybe the documentation is just outdated?

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 17, 2021

it doesn't look like DataGrid takes an apiRef

@cbazza This is correct, apiRef is only available in the Pro plan and upward (XGrid). The docs for the events is confusing https://material-ui.com/components/data-grid/events/. You don't need the apiRef to listen to an event. You can use the props too.

It looks like you have hit the frustration 1. in of #1826.

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! status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it
Projects
None yet
Development

No branches or pull requests

2 participants