Skip to content

Grid: scroll to keep selected cell in view#6

Merged
GordonBeeming merged 1 commit into
mainfrom
gb/grid-scroll-track
Apr 23, 2026
Merged

Grid: scroll to keep selected cell in view#6
GordonBeeming merged 1 commit into
mainfrom
gb/grid-scroll-track

Conversation

@GordonBeeming
Copy link
Copy Markdown
Owner

Summary

  • Wrap the results ScrollView in a ScrollViewReader and call scrollTo whenever model.selectedIndex changes, so arrow-key nav doesn't push the focused cell off-screen.
  • anchor: nil is a bring-into-view scroll, so Left/Right steps inside an already-visible row don't jitter the position.

Test plan

  • swift build passes.
  • Open the panel with enough results to overflow the grid.
  • Hold Down: the highlighted cell scrolls into view as selection drops past the fold.
  • Hold Up: top cell stays visible once reached.
  • Left/Right within a visible row: no scroll jitter.
  • Scroll manually, then arrow back to index 0: grid jumps so cell 0 is visible.

Wrap the results ScrollView in a ScrollViewReader and scroll on
selectedIndex changes so arrow-key nav past the fold doesn't push the
highlighted cell off-screen. anchor: nil is a bring-into-view, so
Left/Right steps inside a visible row don't jitter.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: GitButler <gitbutler@gitbutler.com>
@GordonBeeming GordonBeeming marked this pull request as ready for review April 23, 2026 08:44
Copilot AI review requested due to automatic review settings April 23, 2026 08:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves keyboard navigation in the SwiftUI results grid by automatically scrolling to keep the currently selected result cell visible as selectedIndex changes.

Changes:

  • Wraps the results ScrollView in a ScrollViewReader to enable programmatic scrolling.
  • Adds an onChange handler on model.selectedIndex that scrollTos the newly selected result (using bring-into-view semantics via anchor: nil).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GordonBeeming GordonBeeming merged commit 79eb80a into main Apr 23, 2026
6 checks passed
@GordonBeeming GordonBeeming deleted the gb/grid-scroll-track branch April 23, 2026 08:48
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