From 88478d6b991de50582a6ef85781eed5f56d68dbb Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Fri, 14 Jan 2022 11:42:34 +0100
Subject: chore(toolbar): close modals on click/focus outside

---
 src/components/SearchForm/SearchForm.tsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'src/components/SearchForm/SearchForm.tsx')

diff --git a/src/components/SearchForm/SearchForm.tsx b/src/components/SearchForm/SearchForm.tsx
index c1a7ca7..cefda85 100644
--- a/src/components/SearchForm/SearchForm.tsx
+++ b/src/components/SearchForm/SearchForm.tsx
@@ -13,10 +13,10 @@ const SearchForm = ({ isOpened }: { isOpened: boolean }) => {
 
   useEffect(() => {
     setTimeout(() => {
-      if (inputRef.current) {
+      if (isOpened && inputRef.current) {
         inputRef.current.focus();
       }
-    }, 800);
+    }, 400);
   }, [isOpened]);
 
   const launchSearch = (e: FormEvent) => {
-- 
cgit v1.2.3

