diff --git a/components/popconfirm/__tests__/index.test.tsx b/components/popconfirm/__tests__/index.test.tsx
index 2d6f11e080..b238a95113 100644
--- a/components/popconfirm/__tests__/index.test.tsx
+++ b/components/popconfirm/__tests__/index.test.tsx
@@ -128,6 +128,38 @@ describe('Popconfirm', () => {
jest.useRealTimers();
});
+ it('should be controlled by visible', () => {
+ jest.useFakeTimers();
+ const popconfirm = render(
+
+ show me your code
+ ,
+ );
+
+ expect(popconfirm.container.querySelector('.ant-popover')).toBe(null);
+ popconfirm.rerender(
+
+ show me your code
+ ,
+ );
+
+ expect(popconfirm.container.querySelector('.ant-popover')).not.toBe(null);
+ expect(popconfirm.container.querySelector('.ant-popover')?.className).not.toContain(
+ 'ant-popover-hidden',
+ );
+
+ popconfirm.rerender(
+
+ show me your code
+ ,
+ );
+ act(() => {
+ jest.runAllTimers();
+ });
+ expect(popconfirm.container.querySelector('.ant-popover')).not.toBe(null);
+ jest.useRealTimers();
+ });
+
it('should trigger onConfirm and onCancel', async () => {
const confirm = jest.fn();
const cancel = jest.fn();
diff --git a/components/popconfirm/index.tsx b/components/popconfirm/index.tsx
index b18ac6cd53..de36dd66a9 100644
--- a/components/popconfirm/index.tsx
+++ b/components/popconfirm/index.tsx
@@ -54,8 +54,8 @@ const Popconfirm = React.forwardRef((props, ref) =>
const { getPrefixCls } = React.useContext(ConfigContext);
const [open, setOpen] = useMergedState(false, {
- value: props.open,
- defaultValue: props.defaultOpen,
+ value: props.open ?? props.visible,
+ defaultValue: props.defaultOpen ?? props.defaultVisible,
});
const settingOpen = (