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] Update focused action if the currently focused one is removed #4694

Merged
merged 3 commits into from
May 5, 2022

Conversation

m4theushw
Copy link
Member

@m4theushw m4theushw commented Apr 29, 2022

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.

@mui-bot
Copy link

mui-bot commented Apr 29, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 249.9 416.5 379.4 345.28 67.385
Sort 100k rows ms 479.6 891.2 683.5 703.38 138.77
Select 100k rows ms 118.9 161 130.4 133.68 14.934
Deselect 100k rows ms 126.3 237.1 171.9 180.54 44.342

Generated by 🚫 dangerJS against 1622996

@@ -102,24 +102,20 @@ export default function FullFeaturedCrudGrid() {
event.defaultMuiPrevented = true;
};

const handleEditClick = (id) => (event) => {
event.stopPropagation();
Copy link
Member Author

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.

@m4theushw m4theushw added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Apr 29, 2022
@m4theushw m4theushw self-assigned this Apr 29, 2022
Comment on lines 72 to 75
if (focusedButtonIndex >= numberOfChildren) {
setFocusedButtonIndex(numberOfChildren - 1);
return;
}
Copy link
Member

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

Copy link
Member Author

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.

@github-actions
Copy link

github-actions bot commented May 2, 2022

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 2, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 3, 2022
@m4theushw m4theushw requested a review from alexfauquette May 3, 2022 18:42
@m4theushw m4theushw merged commit 5310bd5 into mui:master May 5, 2022
@m4theushw m4theushw deleted the sanitize-focused-button branch May 5, 2022 17:05
alexfauquette pushed a commit to alexfauquette/mui-x that referenced this pull request Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] GridActionsCell - Error when Using Cancel Button to Leave 'Edit' State
3 participants