From 725ba0b4d2c94b431a7e366a98b8fab8e88fd059 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 6 Jan 2021 11:54:19 -0300 Subject: [PATCH] Adding delay for dynamic --- lib/focus-trap.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/focus-trap.tsx b/lib/focus-trap.tsx index 307ac6dc6..df05f252e 100644 --- a/lib/focus-trap.tsx +++ b/lib/focus-trap.tsx @@ -32,7 +32,7 @@ export default function FocusTrap({ children, focusFirst = false }: Props) { let match = false let end = 20 // Try to find match at least n times. let i = 0 - const timer = setTimeout( + const timer = setInterval( () => { if (!match !== i > end) { match = !!tabbable(root.current).length @@ -40,7 +40,7 @@ export default function FocusTrap({ children, focusFirst = false }: Props) { tabbable(root.current)[0].focus() } } else { - clearTimeout(timer) + clearInterval(timer) } i = i++ console.log('-----------', i)