mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-23 11:59:34 +08:00
fix(components): [popper] (#11377)
* fix(components): [popper] * Fix use-popper integration caused regression. * fix: failing test cases --------- Co-authored-by: JeremyWuuuuu <15975785+JeremyWuuuuu@users.noreply.github.com>
This commit is contained in:
parent
78f235d9c5
commit
f5cf0ad506
@ -1,4 +1,4 @@
|
||||
import { defineComponent, nextTick, ref } from 'vue'
|
||||
import { computed, defineComponent, nextTick, ref } from 'vue'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { POPPER_INJECTION_KEY } from '@element-plus/tokens'
|
||||
@ -12,6 +12,7 @@ const popperInjection = {
|
||||
triggerRef: ref(),
|
||||
popperInstanceRef: ref(),
|
||||
contentRef: ref(),
|
||||
role: computed(() => 'test-role'),
|
||||
}
|
||||
|
||||
const TestComponent = defineComponent({
|
||||
|
@ -11,7 +11,7 @@
|
||||
<el-focus-trap
|
||||
:trapped="trapped"
|
||||
:trap-on-focus-in="true"
|
||||
:focus-trap-el="popperContentRef"
|
||||
:focus-trap-el="contentRef"
|
||||
:focus-start-el="focusStartRef"
|
||||
@focus-after-trapped="onFocusAfterTrapped"
|
||||
@focus-after-released="onFocusAfterReleased"
|
||||
@ -87,7 +87,6 @@ const {
|
||||
})
|
||||
|
||||
const formItemContext = inject(formItemContextKey, undefined)
|
||||
const popperContentRef = ref<HTMLElement>()
|
||||
const arrowOffset = ref<number>()
|
||||
|
||||
provide(POPPER_CONTENT_INJECTION_KEY, {
|
||||
@ -131,8 +130,8 @@ onMounted(() => {
|
||||
triggerTargetAriaStopWatch?.()
|
||||
triggerTargetAriaStopWatch = undefined
|
||||
|
||||
const el = unref(triggerTargetEl || popperContentRef.value)
|
||||
const prevEl = unref(prevTriggerTargetEl || popperContentRef.value)
|
||||
const el = unref(triggerTargetEl || contentRef.value)
|
||||
const prevEl = unref(prevTriggerTargetEl || contentRef.value)
|
||||
|
||||
if (isElement(el)) {
|
||||
triggerTargetAriaStopWatch = watch(
|
||||
@ -168,7 +167,7 @@ defineExpose({
|
||||
/**
|
||||
* @description popper content element
|
||||
*/
|
||||
popperContentRef,
|
||||
popperContentRef: contentRef,
|
||||
/**
|
||||
* @description popperjs instance
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user