Skip to content

fix(getHighlightedIndexOnOpen): remove added check from migration#1692

Merged
silviuaavram merged 3 commits into
masterfrom
fix/remove-added-items-check
Jun 4, 2026
Merged

fix(getHighlightedIndexOnOpen): remove added check from migration#1692
silviuaavram merged 3 commits into
masterfrom
fix/remove-added-items-check

Conversation

@silviuaavram
Copy link
Copy Markdown
Collaborator

@silviuaavram silviuaavram commented Jun 3, 2026

Pull Request

What

Removed added check during the TS migration PR.
Fixes #1688

Why

Causes a regression when opening the menu with a -1 highlighted index.

How

Remove the previously added guard.

Changes

Change getHighlightedIndexOnOpen to remove the guard.

Checklist

  • Documentation
  • Tests
  • TypeScript Types
  • Ready to be merged

Copilot AI review requested due to automatic review settings June 3, 2026 18:10
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 fixes a regression in getHighlightedIndexOnOpen introduced during the TS migration by ensuring -1 (meaning “no highlighted item”) is treated as an intentional, valid highlighted index on menu open—preventing selected-item logic from overriding that state and causing off-by-one navigation behavior.

Changes:

  • Allow initialHighlightedIndex === -1 to be returned when it matches the current state highlighted index.
  • Allow defaultHighlightedIndex === -1 to be returned (even when selectedItem is set), restoring intended precedence.
  • Add unit tests covering the -1 regression scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/hooks/utils/getHighlightedIndexOnOpen.ts Restores -1 handling for initial/default highlighted index on open.
src/hooks/utils/__tests__/getHighlightedIndexOnOpen.test.ts Adds tests to prevent regressions when -1 should be preserved.

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

Comment thread src/hooks/utils/getHighlightedIndexOnOpen.ts Outdated
Comment thread src/hooks/utils/getHighlightedIndexOnOpen.ts Outdated
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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/hooks/utils/getHighlightedIndexOnOpen.ts
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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@silviuaavram silviuaavram merged commit 69e02d8 into master Jun 4, 2026
5 checks passed
@silviuaavram silviuaavram deleted the fix/remove-added-items-check branch June 4, 2026 08:14
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

🎉 This PR is included in version 9.3.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useCombobox: (v9.3.4) — getInputProps overriding disabled, and off-by-one highlight on ArrowDown from an initialSelectedItem

2 participants