diff --git a/docs/en-US/component/popconfirm.md b/docs/en-US/component/popconfirm.md index 27d1396721..18fb5bb65d 100644 --- a/docs/en-US/component/popconfirm.md +++ b/docs/en-US/component/popconfirm.md @@ -55,7 +55,6 @@ popconfirm/trigger-event | ---------------------------------- | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | -------------- | | title | Title | ^[string] | — | | effect ^(2.11.2) | Tooltip theme, built-in theme: `dark` / `light` | ^[enum]`'dark' \| 'light'` / ^[string] | light | -| close-on-press-escape ^(2.11.2) | whether the popConfirm can be closed by pressing ESC | ^[boolean] | true | | confirm-button-text | Confirm button text | ^[string] | — | | cancel-button-text | Cancel button text | ^[string] | — | | confirm-button-type | Confirm button type | ^[enum]`'primary' \| 'success' \| 'warning' \| 'danger' \| 'info' \| 'text'` | primary | diff --git a/packages/components/popconfirm/__tests__/popconfirm.test.tsx b/packages/components/popconfirm/__tests__/popconfirm.test.tsx index a89ec8bd6d..233440fa2e 100644 --- a/packages/components/popconfirm/__tests__/popconfirm.test.tsx +++ b/packages/components/popconfirm/__tests__/popconfirm.test.tsx @@ -43,14 +43,11 @@ describe('Popconfirm.vue', () => { }) it('should close the Popconfirm when pressing Escape', async () => { - const onCancel = vi.fn() - const wrapper = mount({ setup() { return () => (
{AXIOM}
, }} @@ -65,13 +62,11 @@ describe('Popconfirm.vue', () => { triggerEvent(document.body, 'keydown', EVENT_CODE.esc) await nextTick() - expect(onCancel).toHaveBeenCalledTimes(0) + await rAF() - await wrapper.setProps({ closeOnPressEscape: true }) - - triggerEvent(document.body, 'keydown', EVENT_CODE.esc) - await nextTick() - expect(onCancel).toHaveBeenCalledTimes(1) + expect(document.querySelector(selector)!.getAttribute('style')).toContain( + 'display: none' + ) }) describe('teleported API', () => { diff --git a/packages/components/popconfirm/src/popconfirm.ts b/packages/components/popconfirm/src/popconfirm.ts index d95825969f..01a4883258 100644 --- a/packages/components/popconfirm/src/popconfirm.ts +++ b/packages/components/popconfirm/src/popconfirm.ts @@ -82,13 +82,6 @@ export const popconfirmProps = buildProps({ type: [String, Number], default: 150, }, - /** - * @description whether the popConfirm can be closed by pressing ESC - */ - closeOnPressEscape: { - type: Boolean, - default: true, - }, } as const) export const popconfirmEmits = { @@ -99,8 +92,7 @@ export const popconfirmEmits = { /** * @description triggers when click cancel button */ - cancel: (e: MouseEvent | KeyboardEvent) => - e instanceof MouseEvent || e instanceof KeyboardEvent, + cancel: (e: MouseEvent) => e instanceof MouseEvent, } export type PopconfirmEmits = typeof popconfirmEmits diff --git a/packages/components/popconfirm/src/popconfirm.vue b/packages/components/popconfirm/src/popconfirm.vue index ed3de56edd..757ccd3993 100644 --- a/packages/components/popconfirm/src/popconfirm.vue +++ b/packages/components/popconfirm/src/popconfirm.vue @@ -10,42 +10,42 @@ :fallback-placements="['bottom', 'top', 'right', 'left']" :hide-after="hideAfter" :persistent="persistent" + loop + @show="showPopper" >