fix(body): preserve focus during virtual keyboard navigation - #818
Merged
Conversation
spike-rabbit
force-pushed
the
fix/body-preserve-virtual-keyboard-focus
branch
from
August 21, 2026 07:28
0f6ff2a to
05535fa
Compare
9 tasks
There was a problem hiding this comment.
Pull request overview
Fixes focus loss during keyboard navigation when using virtual scrolling by tracking the intended logical row position and restoring focus after the target row renders, while also preventing native focus-induced scrolling.
Changes:
- Introduces an internal
RowLocationtype to represent logical row positions for focus navigation. - Updates
DataTableBodyComponentkeyboard focus handling to support virtualized/lazy-loaded rows (pending focus + scroll-to-index). - Adjusts row/cell focusing to use
preventScrolland adds test coverage for virtual scroll navigation scenarios.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| projects/ngx-datatable/src/lib/types/internal.types.ts | Adds RowLocation to model logical row positions for focus restoration. |
| projects/ngx-datatable/src/lib/components/body/keyboard-navigation.spec.ts | Adds virtual scrolling keyboard navigation tests (down/up, column retention, unloaded rows). |
| projects/ngx-datatable/src/lib/components/body/body.component.ts | Implements pending-focus navigation logic and uses absolute indexes to restore focus after virtualization. |
| projects/ngx-datatable/src/lib/components/body/body-row.component.ts | Uses focus({ preventScroll: true }) and adds scrollIntoView() helper. |
| projects/ngx-datatable/src/lib/components/body/body-cell.component.ts | Uses focus({ preventScroll: true }) to avoid native scroll jumps on focus. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
fh1ch
force-pushed
the
fix/body-preserve-virtual-keyboard-focus
branch
from
August 25, 2026 20:14
05535fa to
cb7ff66
Compare
Track row focus by logical location and restore it after virtualized rows render. Prevent repeated arrow presses from advancing through unloaded rows, and keep focused cells in the same rendered column. Use absolute row indexes consistently, avoid native focus scrolling, and add coverage for grouped, virtualized, and lazy-loaded row navigation.
fh1ch
force-pushed
the
fix/body-preserve-virtual-keyboard-focus
branch
from
August 25, 2026 20:25
cb7ff66 to
605218f
Compare
fh1ch
reviewed
Aug 25, 2026
fh1ch
left a comment
Member
There was a problem hiding this comment.
@spike-rabbit nice one, no findings from my end 🙇
LGTM 👍
fh1ch
approved these changes
Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
Virtual keyboard navigation can lose focus when the adjacent row is outside the rendered range. Repeated key presses may advance through unloaded rows, and cell focus may not remain in the same column.
What is the new behavior?
Focus is tracked by logical row location and restored after virtualized rows render. Navigation waits for unloaded rows, uses absolute row indexes, preserves the focused cell column, and avoids native focus scrolling. Coverage includes grouped, virtualized, and lazy-loaded row navigation.
Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications: N/A
Other information: