From bd6bdbeaa81f1ddb54e4a63a38b9fff4f17646cc Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 6 Jan 2021 11:23:09 -0300 Subject: [PATCH] Adding delay for dynamic --- lib/focus-trap.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/focus-trap.tsx b/lib/focus-trap.tsx index c57822527..980eb23ad 100644 --- a/lib/focus-trap.tsx +++ b/lib/focus-trap.tsx @@ -37,7 +37,10 @@ export default function FocusTrap({ children, focusFirst = false }: Props) { console.log('-----------', i) match = !!tabbable(root.current).length if (match) { - tabbable(root.current)[0].focus() + const delay = i === 0 ? 0 : 100 + setTimeout(() => { + tabbable(root.current)[0].focus() + }, delay) } i = i + 1 }