Skip to content

fix: start arrow key navigation from selected item when no item is highlighted#1400

Open
terminalchai wants to merge 1 commit into
Choices-js:mainfrom
terminalchai:fix/direction-key-start-from-selected-choice
Open

fix: start arrow key navigation from selected item when no item is highlighted#1400
terminalchai wants to merge 1 commit into
Choices-js:mainfrom
terminalchai:fix/direction-key-start-from-selected-choice

Conversation

@terminalchai

@terminalchai terminalchai commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resume arrow-key navigation from the selected choice when no choice is currently highlighted
  • add an e2e regression for closing the dropdown without confirming a temporary highlight

Tests

  • npm run lint:js
  • npx playwright test test-e2e/tests/select-one.spec.ts --project=chromium --grep "arrow key navigation resumes"

@Xon Xon added changes required Pull request requires changes before it can be merged bugfix Pull request that fixes an existing bug labels Apr 22, 2026
…tem is highlighted

When a dropdown is closed without confirming a selection and then reopened,
_onDirectionKey() had no highlighted item in the DOM. The fallback was to
get the first selectable choice, so arrow key navigation always restarted
from item 0 instead of from the currently confirmed selection.

Fix: when there is no highlighted item, fall back to the currently selected
item (is-selected) as the navigation reference for getAdjacentEl(). If
neither exists (first open, nothing selected), the original first-item
fallback is preserved.

Add an e2e test to select-one.spec.ts that verifies ArrowDown after a
close-without-confirm resumes navigation relative to the selected item.

Fixes Choices-js#1371
@terminalchai terminalchai force-pushed the fix/direction-key-start-from-selected-choice branch from f4b0ed4 to d1177e4 Compare May 25, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes an existing bug changes required Pull request requires changes before it can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants