mirror of
https://github.com/vercel/commerce.git
synced 2025-06-18 13:11:23 +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 match = false
|
||||||
let end = 20 // Try to find match at least n times.
|
let end = 20 // Try to find match at least n times.
|
||||||
let i = 0
|
let i = 0
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(
|
||||||
|
() => {
|
||||||
if (!match !== i > end) {
|
if (!match !== i > end) {
|
||||||
match = !!tabbable(root.current).length
|
match = !!tabbable(root.current).length
|
||||||
|
if (root.current) {
|
||||||
tabbable(root.current)[0].focus()
|
tabbable(root.current)[0].focus()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(timer)
|
clearTimeout(timer)
|
||||||
}
|
}
|
||||||
|
i = i++
|
||||||
console.log('-----------', i)
|
console.log('-----------', i)
|
||||||
}, 100)
|
},
|
||||||
|
i < 2 ? 0 : 200
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user