Skip to content

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

Merged
merged 6 commits into from
May 21, 2025
Merged

Fix cell stealing focus on click #3790

merged 6 commits into from
May 21, 2025

Conversation

amanmahajan7
Copy link
Contributor

This was introduced in #3774

@amanmahajan7 amanmahajan7 self-assigned this May 21, 2025
Copy link

codecov bot commented May 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.80%. Comparing base (e80885d) to head (b791afc).
Report is 2 commits behind head on main.

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           
Files with missing lines Coverage Δ
src/Cell.tsx 100.00% <100.00%> (ø)
src/DataGrid.tsx 99.59% <100.00%> (-0.01%) ⬇️
src/GroupRow.tsx 100.00% <100.00%> (ø)
src/hooks/useRovingTabIndex.ts 100.00% <100.00%> (ø)
src/index.ts 100.00% <ø> (ø)
src/types.ts 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -952,7 +953,7 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
isCellWithinBounds: isCellWithinSelectionBounds
});

selectCell(nextSelectedCellPosition);
selectCell(nextSelectedCellPosition, { shouldFocusCell: true });
Copy link
Contributor Author

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>) {
Copy link
Contributor Author

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

@amanmahajan7 amanmahajan7 marked this pull request as ready for review May 21, 2025 18:13
@amanmahajan7 amanmahajan7 requested a review from nstepien as a code owner May 21, 2025 18:13
nstepien
nstepien previously approved these changes May 21, 2025
@amanmahajan7 amanmahajan7 merged commit d38b21b into main May 21, 2025
2 checks passed
@amanmahajan7 amanmahajan7 deleted the am-fix-focus branch May 21, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants