fix: Fix auto complete bugs (#220)

This commit is contained in:
Devansh Jain
2025-12-15 16:45:52 -08:00
committed by GitHub
parent b14a472941
commit 2a5d8dacb1
2 changed files with 19 additions and 25 deletions

View File

@@ -27,7 +27,7 @@ interface UseAutocompleteNavigationResult {
*/
export function useAutocompleteNavigation<T>({
matches,
maxVisible = 10,
maxVisible,
onSelect,
onActiveChange,
manageActiveState = true,
@@ -55,7 +55,11 @@ export function useAutocompleteNavigation<T>({
useInput((_input, key) => {
if (!matches.length || disabled) return;
const maxIndex = Math.min(matches.length, maxVisible) - 1;
// If maxVisible is set, limit navigation to visible items; otherwise navigate all
const maxIndex =
maxVisible !== undefined
? Math.min(matches.length, maxVisible) - 1
: matches.length - 1;
if (key.upArrow) {
setSelectedIndex((prev) => (prev > 0 ? prev - 1 : maxIndex));