mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 12:27:31 +00:00
misc: resolved auto-popup of suggestions
This commit is contained in:
@@ -56,7 +56,9 @@ export const SecretPathInput = ({
|
|||||||
) {
|
) {
|
||||||
setSecretPath(debouncedInputValue);
|
setSecretPath(debouncedInputValue);
|
||||||
}
|
}
|
||||||
|
}, [debouncedInputValue]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
// filter suggestions based on matching
|
// filter suggestions based on matching
|
||||||
const searchFragment = debouncedInputValue.split("/").pop() || "";
|
const searchFragment = debouncedInputValue.split("/").pop() || "";
|
||||||
const filteredSuggestions = folders
|
const filteredSuggestions = folders
|
||||||
@@ -66,7 +68,7 @@ export const SecretPathInput = ({
|
|||||||
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
||||||
|
|
||||||
setSuggestions(filteredSuggestions);
|
setSuggestions(filteredSuggestions);
|
||||||
}, [debouncedInputValue]);
|
}, [debouncedInputValue, folders]);
|
||||||
|
|
||||||
const handleSuggestionSelect = (selectedIndex: number) => {
|
const handleSuggestionSelect = (selectedIndex: number) => {
|
||||||
if (!suggestions[selectedIndex]) {
|
if (!suggestions[selectedIndex]) {
|
||||||
@@ -76,7 +78,7 @@ export const SecretPathInput = ({
|
|||||||
const validPaths = inputValue.split("/");
|
const validPaths = inputValue.split("/");
|
||||||
validPaths.pop();
|
validPaths.pop();
|
||||||
|
|
||||||
const newValue = `${validPaths.join("/")}/${suggestions[selectedIndex]}`;
|
const newValue = `${validPaths.join("/")}/${suggestions[selectedIndex]}/`;
|
||||||
onChange?.(newValue);
|
onChange?.(newValue);
|
||||||
setInputValue(newValue);
|
setInputValue(newValue);
|
||||||
setSecretPath(newValue);
|
setSecretPath(newValue);
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export const useGetFoldersByEnv = ({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
return [...names];
|
return [...names];
|
||||||
}, [(folders || []).map((folder) => folder.data)]);
|
}, [...(folders || []).map((folder) => folder.data)]);
|
||||||
|
|
||||||
const isFolderPresentInEnv = useCallback(
|
const isFolderPresentInEnv = useCallback(
|
||||||
(name: string, env: string) => {
|
(name: string, env: string) => {
|
||||||
@@ -91,7 +91,7 @@ export const useGetFoldersByEnv = ({
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
[(folders || []).map((folder) => folder.data)]
|
[...(folders || []).map((folder) => folder.data)]
|
||||||
);
|
);
|
||||||
|
|
||||||
return { folders, folderNames, isFolderPresentInEnv };
|
return { folders, folderNames, isFolderPresentInEnv };
|
||||||
|
|||||||
Reference in New Issue
Block a user