Add clearTimeout on setTimeouts

This commit is contained in:
carlosmonastyrski
2025-03-31 18:20:01 -03:00
parent c59cecdb45
commit 74200bf860
2 changed files with 8 additions and 3 deletions

View File

@@ -81,12 +81,14 @@ const AccessTreeContent = ({ permissions }: AccessTreeProps) => {
}, [selectedPath, environment]);
useEffect(() => {
let timer: NodeJS.Timeout;
if (initialRender) {
setTimeout(() => {
timer = setTimeout(() => {
goToRootNode();
setInitialRender(false);
}, 500);
}
return () => clearTimeout(timer);
}, [nodes, edges, getViewport(), initialRender]);
const handleToggleModalView = () =>

View File

@@ -29,9 +29,10 @@ export const AccessTreeSecretPathInput = ({
};
const handleBlur = () => {
setTimeout(() => {
const timeout: NodeJS.Timeout = setTimeout(() => {
setIsFocused(false);
}, 200);
return () => clearTimeout(timeout);
};
useEffect(() => {
@@ -50,8 +51,10 @@ export const AccessTreeSecretPathInput = ({
const toggleSearch = () => {
setIsExpanded(!isExpanded);
if (!isExpanded) {
setTimeout(focusInput, 300);
const timeout: NodeJS.Timeout = setTimeout(focusInput, 300);
return () => clearTimeout(timeout);
}
return () => {};
};
return (