mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
fix: unable to close modal when using visible in Modal.confirm().update (#37471)
* fix: unable to close modal when using visible in Modal.confirm().update * chore: test case update Co-authored-by: yangguangte <yangguangte@bytedance.com> Co-authored-by: 二货机器人 <smith3816@gmail.com>
This commit is contained in:
parent
7c087deded
commit
87f39244e1
@ -850,4 +850,31 @@ describe('Modal.confirm triggers callbacks correctly', () => {
|
||||
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/37461
|
||||
it('Update should closable', async () => {
|
||||
jest.useFakeTimers();
|
||||
|
||||
Modal.confirm({}).update({
|
||||
visible: true,
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
jest.runAllTimers();
|
||||
await sleep();
|
||||
});
|
||||
|
||||
expect($$('.ant-modal-confirm-confirm')).toHaveLength(1);
|
||||
|
||||
$$('.ant-modal-confirm-btns > .ant-btn')[0].click();
|
||||
|
||||
await act(async () => {
|
||||
jest.runAllTimers();
|
||||
await sleep();
|
||||
});
|
||||
|
||||
expect($$('.ant-modal-confirm-confirm')).toHaveLength(0);
|
||||
|
||||
jest.useRealTimers();
|
||||
});
|
||||
});
|
||||
|
@ -48,7 +48,14 @@ export default function confirm(config: ModalFuncProps) {
|
||||
reactUnmount(container);
|
||||
}
|
||||
|
||||
function render({ okText, cancelText, prefixCls: customizePrefixCls, ...props }: any) {
|
||||
function render({
|
||||
okText,
|
||||
cancelText,
|
||||
prefixCls: customizePrefixCls,
|
||||
open,
|
||||
visible,
|
||||
...props
|
||||
}: any) {
|
||||
/**
|
||||
* https://github.com/ant-design/ant-design/issues/23623
|
||||
*
|
||||
@ -65,6 +72,7 @@ export default function confirm(config: ModalFuncProps) {
|
||||
reactRender(
|
||||
<ConfirmDialog
|
||||
{...props}
|
||||
open={open ?? visible}
|
||||
prefixCls={prefixCls}
|
||||
rootPrefixCls={rootPrefixCls}
|
||||
iconPrefixCls={iconPrefixCls}
|
||||
|
@ -13,6 +13,7 @@ const DEPRECIATED_VERSION = {
|
||||
'https://github.com/ant-design/ant-design/pull/36800',
|
||||
'https://github.com/ant-design/ant-design/issues/37024',
|
||||
],
|
||||
'4.23.0': ['https://github.com/ant-design/ant-design/issues/37461'],
|
||||
};
|
||||
|
||||
function matchDeprecated(version) {
|
||||
|
Loading…
Reference in New Issue
Block a user