Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: resolved loop traversal of suggestions

Sheen Capadngancc25639157ea
diff --git a/frontend/src/components/v2/SecretPathInput/SecretPathInput.tsx b/frontend/src/components/v2/SecretPathInput/SecretPathInput.tsx
index 348da6a88a..fb110c2e70 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<HTMLInputElement>) => {
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);
}