mirror of
https://github.com/vercel/commerce.git
synced 2025-06-18 05:01:22 +00:00
Adding delay for dynamic
This commit is contained in:
parent
4594945e02
commit
f3aab45390
@ -32,15 +32,21 @@ 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(() => {
|
||||
if (!match !== i > end) {
|
||||
match = !!tabbable(root.current).length
|
||||
tabbable(root.current)[0].focus()
|
||||
} else {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
console.log('-----------', i)
|
||||
}, 100)
|
||||
const timer = setTimeout(
|
||||
() => {
|
||||
if (!match !== i > end) {
|
||||
match = !!tabbable(root.current).length
|
||||
if (root.current) {
|
||||
tabbable(root.current)[0].focus()
|
||||
}
|
||||
} else {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
i = i++
|
||||
console.log('-----------', i)
|
||||
},
|
||||
i < 2 ? 0 : 200
|
||||
)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user