Skip to content

fix(app): handle Up from no selection in directory picker - #45096

Open
arpankanwer wants to merge 1 commit into
anomalyco:devfrom
arpankanwer:fix/44960-directory-picker-up-navigation
Open

fix(app): handle Up from no selection in directory picker#45096
arpankanwer wants to merge 1 commit into
anomalyco:devfrom
arpankanwer:fix/44960-directory-picker-up-navigation

Conversation

@arpankanwer

@arpankanwer arpankanwer commented Aug 25, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #44960

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

nextSuggestionIndex in packages/app/src/components/directory-picker-domain.ts:218 used (current + delta + count) % count. With initial activeSuggestion = -1 (no selection), Up (-1) from -1 gave count-2 (penultimate) instead of count-1 (last). Down was correct by accident.

Added explicit handling for the -1 sentinel: return 0 for Down and count-1 for Up. Only this function is touched, used by dialog-select-directory-v2.tsx.

How did you verify your code works?

  • Ran bun --cwd packages/app test src/components/directory-picker-domain.test.ts — 23 pass, 0 fail (78 expects).
  • Checked the specific case: nextSuggestionIndex(-1, -1, 4) now returns 3 (was 2), and (-1, 1, 4)=0, (3,1,4)=0, (0,-1,4)=3 unchanged.

Screenshots / recordings

N/A — keyboard navigation fix, verified via unit test.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

nextSuggestionIndex assumed current was always in [0,count) and used
(current+delta+count)%count, so Up (-1) from no-selection (-1) wrapped
to penultimate (count-2) instead of last (count-1). Down was correct.
Handle the sentinel -1 explicitly so initial Up mirrors initial Down.

Fixes anomalyco#44960
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@arpankanwer
arpankanwer marked this pull request as ready for review August 25, 2026 23:07
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.

Directory picker skips the last suggestion when Up is pressed initially

1 participant