-
-
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] Remove focus on cell when its row is removed from the data #1995
[DataGrid] Remove focus on cell when its row is removed from the data #1995
Conversation
The issue occurred when removing a row that had a cell focused when removing it. I'm not sure what the best solution here is. Of course this would require a new test once a solution is decided. Another issue here is that the typing of getRow: (id: GridRowId) => GridRowModel; |
The solution looks fine. |
OK, I'll add some test for the current behavior change |
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.
The bug is fixed: https://codesandbox.io/s/zen-darkness-fyjex 👍. I wonder about:
- Would we have the same issue with a removed column? Maybe we shouldn't are yet.
- Is the cleanup done soon enough? It seems to, it runs in the same effect timing than
convertGridRowsPropToState
.
}); | ||
}); | ||
|
||
it('should reset focus when removing the row containing the focus cell', async () => { |
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.
it('should reset focus when removing the row containing the focus cell', async () => { | |
it('should reset focus when removing the row containing the focus cell', () => { |
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 think that there is a broader subject than just row removal here indeed. Could there be the same behavior for other things than just focus ?
-
I also think so.
expect(apiRef.current.getState().focus.cell).to.equal(null); | ||
}); | ||
|
||
it('should not reset focus when removing a row not containing the focus cell', async () => { |
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.
it('should not reset focus when removing a row not containing the focus cell', async () => { | |
it('should not reset focus when removing a row not containing the focus cell', () => { |
@flaviendelangle Hey ! Thanks for the fix, when this one will be published in an npm release ? |
@magrinj Next up on our release round-robin is Damien. The last release was 2 weeks ago, so I assume it will happen soon or later. |
Fixes #1958