-
-
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
[DataGrid] Keep focused cell in the DOM #5911
Conversation
These are the results for the performance tests:
|
8184c8c
to
07fa30b
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
ed1b868
to
cf78d03
Compare
Since we are doing this should we also consider this ticket #4282? |
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.
Great solution!
@@ -536,9 +536,9 @@ describe('<DataGrid /> - Keyboard', () => { | |||
const input = screen.getByTestId('custom-input'); | |||
input.focus(); | |||
fireEvent.keyDown(input, { key: 'a' }); | |||
expect(renderCell.callCount).to.equal(4); | |||
expect(renderCell.callCount).to.equal(6); |
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.
Why was this test impacted by the changes? It only renders one row, so it should not be impacted by virtualization
@@ -425,6 +427,9 @@ const DataGridProVirtualScroller = React.forwardRef< | |||
<GridVirtualScrollerRenderZone {...getRenderZoneProps()}> | |||
{mainRows} | |||
</GridVirtualScrollerRenderZone> | |||
<GridVirtualScrollerRenderZone {...getFocusRenderZoneProps()}> | |||
{getFocusedRow()} |
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've noticed scroll jump when checkbox cell is focused.
Doesn't happen if regular cell is focused though.
Screen.Recording.2022-09-28.at.13.39.42.mov
@@ -425,6 +427,9 @@ const DataGridProVirtualScroller = React.forwardRef< | |||
<GridVirtualScrollerRenderZone {...getRenderZoneProps()}> | |||
{mainRows} | |||
</GridVirtualScrollerRenderZone> | |||
<GridVirtualScrollerRenderZone {...getFocusRenderZoneProps()}> | |||
{getFocusedRow()} |
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.
Moving focus to checkbox cell acts weird when focus is out of view:
Screen.Recording.2022-09-28.at.13.40.53.mov
@@ -425,6 +427,9 @@ const DataGridProVirtualScroller = React.forwardRef< | |||
<GridVirtualScrollerRenderZone {...getRenderZoneProps()}> | |||
{mainRows} | |||
</GridVirtualScrollerRenderZone> | |||
<GridVirtualScrollerRenderZone {...getFocusRenderZoneProps()}> |
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.
We might consider similar solution for columns virtualization, since we have the same problem with horizontal scrolling
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Preview: https://deploy-preview-5911--material-ui-x.netlify.app/x/react-data-grid/#commercial-version
Fixes #5750
The idea to fix this issue was to check if the row belonging to the focused cell is visible and, if not, render the entire row only to keep the same focused element. This prevent the focused element being changed to
document.body
that happens if thedocument.activeElement
is removed from the DOM.