From 01c66d79afb8ff24255f593ca20ec4ac88f4b340 Mon Sep 17 00:00:00 2001 From: Fernando Zanutto Date: Tue, 23 Apr 2024 19:25:47 -0300 Subject: [PATCH 1/5] fix: add handleCloseClick to useEffect dependency --- src/renderer/components/modal/modal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/modal/modal.tsx b/src/renderer/components/modal/modal.tsx index cc75db26..f2575e1f 100644 --- a/src/renderer/components/modal/modal.tsx +++ b/src/renderer/components/modal/modal.tsx @@ -57,7 +57,7 @@ export function Modal({ window.addEventListener("keydown", onKeyDown); return () => window.removeEventListener("keydown", onKeyDown); - }, []); + }, [handleCloseClick]); useEffect(() => { const onMouseDown = (e: MouseEvent) => { @@ -74,7 +74,7 @@ export function Modal({ window.addEventListener("mousedown", onMouseDown); return () => window.removeEventListener("mousedown", onMouseDown); - }, []); + }, [handleCloseClick]); useEffect(() => { dispatch(toggleDragging(visible)); From 7ba7391c833c145f5d7709afefbc342182a39763 Mon Sep 17 00:00:00 2001 From: Fernando Zanutto Date: Tue, 23 Apr 2024 19:28:32 -0300 Subject: [PATCH 2/5] fix: remove unused variable --- src/renderer/components/modal/modal.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/renderer/components/modal/modal.tsx b/src/renderer/components/modal/modal.tsx index f2575e1f..288930e3 100644 --- a/src/renderer/components/modal/modal.tsx +++ b/src/renderer/components/modal/modal.tsx @@ -1,4 +1,4 @@ -import { useEffect, useId, useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { createPortal } from "react-dom"; import { XIcon } from "@primer/octicons-react"; @@ -24,7 +24,6 @@ export function Modal({ const [isClosing, setIsClosing] = useState(false); const dispatch = useAppDispatch(); const modalContentRef = useRef(null); - const componentId = useId(); const handleCloseClick = () => { setIsClosing(true); From d11c142032194ed87a220fedb7ebc4a039cc93fa Mon Sep 17 00:00:00 2001 From: Fernando Zanutto Date: Tue, 23 Apr 2024 19:35:40 -0300 Subject: [PATCH 3/5] trigger pipeline --- src/renderer/components/modal/modal.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/renderer/components/modal/modal.tsx b/src/renderer/components/modal/modal.tsx index 288930e3..33e07680 100644 --- a/src/renderer/components/modal/modal.tsx +++ b/src/renderer/components/modal/modal.tsx @@ -33,6 +33,7 @@ export function Modal({ if (time - zero <= 400) { requestAnimationFrame(animateClosing); } else { + onClose(); setIsClosing(false); } From 6131c1406793414364e1502e073facdc1715a924 Mon Sep 17 00:00:00 2001 From: Fernando Zanutto Date: Tue, 23 Apr 2024 19:35:48 -0300 Subject: [PATCH 4/5] trigger pipeline --- src/renderer/components/modal/modal.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/renderer/components/modal/modal.tsx b/src/renderer/components/modal/modal.tsx index 33e07680..288930e3 100644 --- a/src/renderer/components/modal/modal.tsx +++ b/src/renderer/components/modal/modal.tsx @@ -33,7 +33,6 @@ export function Modal({ if (time - zero <= 400) { requestAnimationFrame(animateClosing); } else { - onClose(); setIsClosing(false); } From b60c319dfd675ec7ebfcde468e94ebd217e3b362 Mon Sep 17 00:00:00 2001 From: Fernando Zanutto Date: Tue, 23 Apr 2024 19:44:01 -0300 Subject: [PATCH 5/5] lint warnings --- src/renderer/components/modal/modal.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/modal/modal.tsx b/src/renderer/components/modal/modal.tsx index 288930e3..9b5f8cf5 100644 --- a/src/renderer/components/modal/modal.tsx +++ b/src/renderer/components/modal/modal.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; import { createPortal } from "react-dom"; import { XIcon } from "@primer/octicons-react"; @@ -25,7 +25,7 @@ export function Modal({ const dispatch = useAppDispatch(); const modalContentRef = useRef(null); - const handleCloseClick = () => { + const handleCloseClick = useCallback(() => { setIsClosing(true); const zero = performance.now(); @@ -37,7 +37,7 @@ export function Modal({ setIsClosing(false); } }); - }; + }, [onClose]); const isTopMostModal = () => { const openModals = document.querySelectorAll("[role=modal]");