diff --git a/packages/components/popconfirm/__tests__/popconfirm.test.tsx b/packages/components/popconfirm/__tests__/popconfirm.test.tsx
index 233440fa2e..286d5eeb42 100644
--- a/packages/components/popconfirm/__tests__/popconfirm.test.tsx
+++ b/packages/components/popconfirm/__tests__/popconfirm.test.tsx
@@ -1,4 +1,4 @@
-import { nextTick } from 'vue'
+import { nextTick, ref } from 'vue'
import { mount } from '@vue/test-utils'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { rAF } from '@element-plus/test-utils/tick'
@@ -69,6 +69,58 @@ describe('Popconfirm.vue', () => {
)
})
+ it('should work with virtualTriggering and virtualRef', async () => {
+ const wrapper = mount({
+ setup() {
+ const visible = ref(false)
+ const virtualRef = ref()
+ const handleClick = () => {
+ virtualRef.value = {
+ getBoundingClientRect: () => {
+ return {
+ x: 0,
+ y: 0,
+ top: 0,
+ left: 0,
+ width: 100,
+ height: 100,
+ right: 100,
+ bottom: 100,
+ }
+ },
+ }
+ visible.value = true
+ }
+
+ return () => (
+ <>
+
+
+ >
+ )
+ },
+ })
+
+ await nextTick()
+
+ const popperEl = document.querySelector(selector)!
+ expect(popperEl.getAttribute('style')).toContain('display: none')
+ const button = wrapper.find('button[data-testid="testid"]')
+
+ await button.trigger('click')
+ await nextTick()
+ await rAF()
+ const style = popperEl.getAttribute('style')
+ expect(style).not.toContain('display: none')
+ expect(style).toContain('transform: translate(0px, 112px)')
+ })
+
describe('teleported API', () => {
it('should mount on popper container', async () => {
expect(document.body.innerHTML).toBe('')
diff --git a/packages/components/popconfirm/src/popconfirm.vue b/packages/components/popconfirm/src/popconfirm.vue
index 757ccd3993..0add44fe43 100644
--- a/packages/components/popconfirm/src/popconfirm.vue
+++ b/packages/components/popconfirm/src/popconfirm.vue
@@ -4,6 +4,8 @@
trigger="click"
:effect="effect"
v-bind="$attrs"
+ :virtual-triggering="virtualTriggering"
+ :virtual-ref="virtualRef"
:popper-class="`${ns.namespace.value}-popover`"
:popper-style="style"
:teleported="teleported"