-
-
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] Update focused action if the currently focused one is removed #4694
Conversation
These are the results for the performance tests:
|
@@ -102,24 +102,20 @@ export default function FullFeaturedCrudGrid() { | |||
event.defaultMuiPrevented = true; | |||
}; | |||
|
|||
const handleEditClick = (id) => (event) => { | |||
event.stopPropagation(); |
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.
Any event.stopPropagation()
call prevents the grid from updating the internal state.
if (focusedButtonIndex >= numberOfChildren) { | ||
setFocusedButtonIndex(numberOfChildren - 1); | ||
return; | ||
} |
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 get why you have this correction of focusedButtonIndex
compared to numberOfChildren
, and in another useEffect
you do a similar check with numberOfButtons
.
Maybe one correction with either numberOfChildren
or numberOfButtons
is enought
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 removed setFocusedButtonIndex
from the code highlighted. There's another effect that updates the state.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Fixes #4675
When I did #4325 I didn't realize that the number of actions could change and the index storing which button has focus should be updated. This PR is fixing this by checking if the index is greater than the number of actions, if true put focus on the last button.