From cc25639157ea3d349db7317d9b27b27c5bc7ce3d Mon Sep 17 00:00:00 2001 From: Sheen Capadngan Date: Fri, 26 Apr 2024 18:59:39 +0800 Subject: [PATCH] fix: resolved loop traversal of suggestions --- .../src/components/v2/SecretPathInput/SecretPathInput.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/v2/SecretPathInput/SecretPathInput.tsx b/frontend/src/components/v2/SecretPathInput/SecretPathInput.tsx index 348da6a88..fb110c2e7 100644 --- a/frontend/src/components/v2/SecretPathInput/SecretPathInput.tsx +++ b/frontend/src/components/v2/SecretPathInput/SecretPathInput.tsx @@ -93,9 +93,9 @@ export const SecretPathInput = ({ const handleKeyDown = (e: React.KeyboardEvent) => { const mod = (n: number, m: number) => ((n % m) + m) % m; if (e.key === "ArrowDown") { - setHighlightedIndex((prevIndex) => mod(prevIndex + 1, folders.length)); + setHighlightedIndex((prevIndex) => mod(prevIndex + 1, suggestions.length)); } else if (e.key === "ArrowUp") { - setHighlightedIndex((prevIndex) => mod(prevIndex - 1, folders.length)); + setHighlightedIndex((prevIndex) => mod(prevIndex - 1, suggestions.length)); } else if (e.key === "Enter" && highlightedIndex >= 0) { handleSuggestionSelect(highlightedIndex); }