mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-18 10:59:10 +08:00
fix(components): [focus-trap] respect focusout null relatedTarget (#7915)
* fix(components): [focus-trap] respect focusout null relatedTarget * fix(components): [focus-trap] use right variable this time Co-authored-by: OpenGraphica <opengraphica@gmail.com>
This commit is contained in:
parent
49ed2f6907
commit
b6049dab1c
@ -12,6 +12,7 @@ import {
|
|||||||
unref,
|
unref,
|
||||||
watch,
|
watch,
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
|
import { isNil } from 'lodash-unified'
|
||||||
import { EVENT_CODE } from '@element-plus/constants'
|
import { EVENT_CODE } from '@element-plus/constants'
|
||||||
import { useEscapeKeydown } from '@element-plus/hooks'
|
import { useEscapeKeydown } from '@element-plus/hooks'
|
||||||
import { isString } from '@element-plus/utils'
|
import { isString } from '@element-plus/utils'
|
||||||
@ -168,11 +169,9 @@ export default defineComponent({
|
|||||||
if (focusLayer.paused || !trapContainer) return
|
if (focusLayer.paused || !trapContainer) return
|
||||||
|
|
||||||
if (props.trapped) {
|
if (props.trapped) {
|
||||||
if (
|
const relatedTarget = (e as FocusEvent)
|
||||||
!trapContainer.contains(
|
.relatedTarget as HTMLElement | null
|
||||||
(e as FocusEvent).relatedTarget as HTMLElement | null
|
if (!isNil(relatedTarget) && !trapContainer.contains(relatedTarget)) {
|
||||||
)
|
|
||||||
) {
|
|
||||||
tryFocus(lastFocusAfterTrapped, true)
|
tryFocus(lastFocusAfterTrapped, true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user