Skip to content

feat(hooks): skip disabled items when opening with arrows#1696

Draft
wanxiankai wants to merge 1 commit into
downshift-js:masterfrom
wanxiankai:feat/skip-disabled-on-arrow-open
Draft

feat(hooks): skip disabled items when opening with arrows#1696
wanxiankai wants to merge 1 commit into
downshift-js:masterfrom
wanxiankai:feat/skip-disabled-on-arrow-open

Conversation

@wanxiankai

Copy link
Copy Markdown

Pull Request

What

Skip disabled items when useSelect or useCombobox opens with ArrowDown or ArrowUp, and highlight the first enabled item in the requested direction.

Closes #1593.

Why

The current open-on-arrow logic only checks index 0 for ArrowDown and the last index for ArrowUp. If that edge item is disabled, the menu opens without an active descendant even when enabled items are available, which is confusing for keyboard and assistive-technology users.

How

Reuse the existing getNonDisabledIndex traversal helper from getHighlightedIndexOnOpen. The search begins at the first item for ArrowDown and the last item for ArrowUp. If every item is disabled, the helper preserves the existing -1 result and the menu opens without a highlight.

Changes

  • Update the shared open-on-arrow highlighted-index calculation.
  • Cover forward, backward, consecutive-disabled, and all-disabled cases at the utility level.
  • Add integration regressions for both useSelect and useCombobox in both arrow directions.

Validation

  • Targeted Jest: 3 suites, 331 tests, 12 snapshots passed.
  • Full coverage Jest: 92 suites, 1,118 tests, 49 snapshots passed; 100% statements, branches, functions, and lines.
  • npm run test:ts
  • Changed-file ESLint and Prettier checks.
  • Bundle build and 8 build-output tests.
  • SSR test.
  • Docusaurus production build.

Local Playwright execution was not available because the Chromium download CDN repeatedly reset the TLS connection; the repository CI matrix will run the end-to-end suite.

Checklist

  • Documentation — N/A; no public API change
  • Tests
  • TypeScript Types — N/A; no type surface change
  • Ready to be merged

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.

Select / highlight first item, that is not disabled when using arrow keys to open the menu

1 participant