-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[docs] Explain how to manage focus with renderCell
#4254
Conversation
These are the results for the performance tests:
|
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.
Could you also stop the ripple when the cell loses focus?
mui-x/packages/grid/x-data-grid/src/components/columnSelection/GridCellCheckboxRenderer.tsx
Lines 68 to 76 in 249969c
React.useLayoutEffect(() => { | |
if (hasFocus) { | |
const input = checkboxElement.current?.querySelector('input'); | |
input?.focus(); | |
} else if (rippleRef.current) { | |
// Only available in @mui/material v5.4.1 or later | |
rippleRef.current.stop({}); | |
} | |
}, [hasFocus]); |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
If you are customizing cell rendering with [`renderCell`](/components/data-grid/columns/#render-cell) method, you become responsible of removing focusable elements from the page tab sequence. | ||
To do so, use the `hasFocus` property from the `renderCell` input, to know if the rendered cell has the focus, and so if the elements should be removed from the tab sequence. |
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.
I don't think using "focusable elements" here is correct. An element can be focusable but not tabbable. What happens is that some HTML elements have implicit tabIndex=0
, e.g. <a />
.
If you are customizing cell rendering with [`renderCell`](/components/data-grid/columns/#render-cell) method, you become responsible of removing focusable elements from the page tab sequence. | |
To do so, use the `hasFocus` property from the `renderCell` input, to know if the rendered cell has the focus, and so if the elements should be removed from the tab sequence. | |
If you are customizing cell rendering with [`renderCell`](/components/data-grid/columns/#render-cell) method, you become responsible for removing focusable elements from the page tab sequence. | |
To do so, use the `tabIndex` prop passed to the `renderCell` params, to know if the rendered cell has the focus, and so if the elements should be removed from the tab sequence. |
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.
I replaced the use of hasFocus
by tabIndex
in the demo too.
|
||
export default function FocusManagement() { | ||
return ( | ||
<div style={{ width: '100%', display: 'flex', justifyContent: 'space-between' }}> |
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.
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.
I used hideFooterSelectedRowCount
to avoid having the "selected row count" modifying the width of the table
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.
I'm not very sure if we should keep two grids inside the same demo. The "reset focus" button is very useful to test the accessibility here. If I click it the focus goes to the first grid.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
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.
Once #4600 is merged we can add a link to the newly added section: #4600 (comment)
|
||
export default function FocusManagement() { | ||
return ( | ||
<div style={{ width: '100%', display: 'flex', justifyContent: 'space-between' }}> |
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.
I'm not very sure if we should keep two grids inside the same demo. The "reset focus" button is very useful to test the accessibility here. If I click it the focus goes to the first grid.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Co-authored-by: Matheus Wichman <matheushw@outlook.com>
@@ -1,25 +1,55 @@ | |||
import * as React from 'react'; | |||
import Button from '@mui/material/Button'; | |||
import { TouchRippleActions } from '@mui/material/ButtonBase/TouchRipple'; |
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.
This is a private type import (more than 1 folder level deep) 🚫, we will need to change this. More details in https://mui.com/material-ui/guides/minimizing-bundle-size/.
Co-authored-by: Matheus Wichman <matheushw@outlook.com>
Preview: https://deploy-preview-4254--material-ui-x.netlify.app/x/react-data-grid/accessibility/#tab-sequence
Part of #4219
The goal of this PR is to explain in the doc how to remove focusable elements from the tab sequence if the cell does not have the focus