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:
Jeremy 2023-02-01 19:50:26 +08:00 committed by GitHub
parent 78f235d9c5
commit f5cf0ad506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -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({

View File

@ -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
*/