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]); }, [selectedPath, environment]);
useEffect(() => { useEffect(() => {
let timer: NodeJS.Timeout;
if (initialRender) { if (initialRender) {
setTimeout(() => { timer = setTimeout(() => {
goToRootNode(); goToRootNode();
setInitialRender(false); setInitialRender(false);
}, 500); }, 500);
} }
return () => clearTimeout(timer);
}, [nodes, edges, getViewport(), initialRender]); }, [nodes, edges, getViewport(), initialRender]);
const handleToggleModalView = () => const handleToggleModalView = () =>

View File

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