[DataGrid] Restore focus after dismissing column menu #5027
+79
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Preview: https://deploy-preview-5027--material-ui-x.netlify.app/x/react-data-grid/demo/
Fixes #1873
This bug happens because, when the column menu is closed, the browser puts focus back to the menu button. However, this button only appears on hover. The problem is that as soon as it receives focus it becomes invisible and the focus is moved to the
<body>
. The solution I used is to focus the column header when I detect that the menu button was focused because the column menu was closed (checkingevent.relatedTarget
). Like #1873, we also have problem in the panels (columns and filters). We don't restore the focus to any element, making it difficult to navigate via keyboard. I'll open another issue for them.