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
725ba0b4d2
commit
87be4c8c5c
@ -29,21 +29,22 @@ export default function FocusTrap({ children, focusFirst = false }: Props) {
|
||||
|
||||
const selectFirstFocusableEl = () => {
|
||||
// Try to find focusable elements, if match then focus.
|
||||
// Up to 4 seconds of load time threshold
|
||||
let match = false
|
||||
let end = 20 // Try to find match at least n times.
|
||||
let end = 22 // Try to find match at least n times.
|
||||
let i = 0
|
||||
const timer = setInterval(
|
||||
() => {
|
||||
console.log('-----------', i)
|
||||
if (!match !== i > end) {
|
||||
match = !!tabbable(root.current).length
|
||||
if (root.current) {
|
||||
tabbable(root.current)[0].focus()
|
||||
}
|
||||
i = i + 1
|
||||
} else {
|
||||
clearInterval(timer)
|
||||
}
|
||||
i = i++
|
||||
console.log('-----------', i)
|
||||
},
|
||||
i < 2 ? 0 : 200
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user