fix(components): [focus-trap] popper input focus (#8025)

* fix(components): [focus-trap] fix reclaim focus for paused layer

* fix(components): [focus-trap] remove async
This commit is contained in:
opengraphica 2022-06-01 03:05:36 -04:00 committed by GitHub
parent 60cd22b890
commit 6359538a45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -172,8 +172,13 @@ export default defineComponent({
const relatedTarget = (e as FocusEvent)
.relatedTarget as HTMLElement | null
if (!isNil(relatedTarget) && !trapContainer.contains(relatedTarget)) {
// Give embedded focus layer time to pause this layer before reclaiming focus
setTimeout(() => {
if (!focusLayer.paused) {
tryFocus(lastFocusAfterTrapped, true)
}
}, 0)
}
} else {
const target = e.target as HTMLElement | null
const isFocusedInTrap = target && trapContainer.contains(target)