fix(components): [focus-trap] maximum call stack size exceeded error (#8218)

* fix(components): [focus-trap] add debounce for emit `focusin` event

* chore: update

* chore: update
This commit is contained in:
webfansplz 2022-07-13 09:50:09 +08:00 committed by GitHub
parent 9fef09333f
commit 006cc3dc24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,13 +151,13 @@ const onFocusAfterReleased = () => {
const onFocusInTrap = (event: FocusEvent) => { const onFocusInTrap = (event: FocusEvent) => {
if (props.visible && !trapped.value) { if (props.visible && !trapped.value) {
if (event.relatedTarget) {
;(event.relatedTarget as HTMLElement)?.focus()
}
if (event.target) { if (event.target) {
focusStartRef.value = event.target as typeof focusStartRef.value focusStartRef.value = event.target as typeof focusStartRef.value
} }
trapped.value = true trapped.value = true
if (event.relatedTarget) {
;(event.relatedTarget as HTMLElement)?.focus()
}
} }
} }