-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix cell stealing focus on click #3790
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3790 +/- ##
=======================================
Coverage 98.80% 98.80%
=======================================
Files 46 46
Lines 3516 3518 +2
Branches 766 766
=======================================
+ Hits 3474 3476 +2
Misses 42 42
🚀 New features to boost your workflow:
|
@@ -952,7 +953,7 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr | |||
isCellWithinBounds: isCellWithinSelectionBounds | |||
}); | |||
|
|||
selectCell(nextSelectedCellPosition); | |||
selectCell(nextSelectedCellPosition, { shouldFocusCell: true }); |
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 only need to set shouldFocusCell
flag on cell navigation using keyboard.
@@ -12,6 +12,15 @@ export function useRovingTabIndex(isSelected: boolean) { | |||
function onFocus(event: React.FocusEvent<HTMLDivElement>) { |
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.
When a cell is clicked it is automatically focused as the cell has a tabIndex: -1
. We can focus the child here
Co-authored-by: Nicolas Stepien <[email protected]>
This was introduced in #3774