Skip to content

Commit 3bd603f

Browse files
committed
fix: replace onOpenChange with afterOpenChange
1 parent e24b8d1 commit 3bd603f

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/Dialog/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import * as React from 'react';
2-
import { useRef, useEffect } from 'react';
31
import classNames from 'classnames';
4-
import KeyCode from 'rc-util/lib/KeyCode';
5-
import useId from 'rc-util/lib/hooks/useId';
62
import contains from 'rc-util/lib/Dom/contains';
3+
import useId from 'rc-util/lib/hooks/useId';
4+
import KeyCode from 'rc-util/lib/KeyCode';
75
import pickAttrs from 'rc-util/lib/pickAttrs';
6+
import * as React from 'react';
7+
import { useEffect, useRef } from 'react';
88
import type { IDialogPropTypes } from '../IDialogPropTypes';
9-
import Mask from './Mask';
109
import { getMotionName } from '../util';
1110
import Content from './Content';
1211
import type { ContentRef } from './Content/Panel';
12+
import Mask from './Mask';
1313

1414
export default function Dialog(props: IDialogPropTypes) {
1515
const {
@@ -25,7 +25,7 @@ export default function Dialog(props: IDialogPropTypes) {
2525
wrapClassName,
2626
wrapProps,
2727
onClose,
28-
onOpenChange,
28+
afterOpenChange,
2929
afterClose,
3030

3131
// Dialog
@@ -87,7 +87,7 @@ export default function Dialog(props: IDialogPropTypes) {
8787
afterClose?.();
8888
}
8989
}
90-
onOpenChange?.(newVisible);
90+
afterOpenChange?.(newVisible);
9191
}
9292

9393
function onInternalClose(e: React.SyntheticEvent) {

src/IDialogPropTypes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type IDialogPropTypes = {
88
mask?: boolean;
99
children?: any;
1010
afterClose?: () => any;
11-
onOpenChange?: (open: boolean) => void;
11+
afterOpenChange?: (open: boolean) => void;
1212
onClose?: (e: SyntheticEvent) => any;
1313
closable?: boolean;
1414
maskClosable?: boolean;

tests/index.spec.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable react/no-render-return-value, max-classes-per-file, func-names, no-console */
2-
import React, { cloneElement, useEffect } from 'react';
3-
import { act } from 'react-dom/test-utils';
42
import { render } from '@testing-library/react';
53
import type { ReactWrapper } from 'enzyme';
64
import { mount } from 'enzyme';
75
import KeyCode from 'rc-util/lib/KeyCode';
6+
import React, { cloneElement, useEffect } from 'react';
7+
import { act } from 'react-dom/test-utils';
88
import type { DialogProps } from '../src';
99
import Dialog from '../src';
1010

@@ -506,17 +506,17 @@ describe('dialog', () => {
506506
});
507507
});
508508

509-
describe('onOpenChange', () => {
510-
it('should trigger onOpenChange when visible changed', () => {
511-
const onOpenChange = jest.fn();
509+
describe('afterOpenChange', () => {
510+
it('should trigger afterOpenChange when visible changed', () => {
511+
const afterOpenChange = jest.fn();
512512

513-
const wrapper = mount(<Dialog onOpenChange={onOpenChange} visible />);
513+
const wrapper = mount(<Dialog afterOpenChange={afterOpenChange} visible />);
514514
jest.runAllTimers();
515515

516516
wrapper.setProps({ visible: false });
517517
jest.runAllTimers();
518518

519-
expect(onOpenChange).toHaveBeenCalledTimes(2);
519+
expect(afterOpenChange).toHaveBeenCalledTimes(2);
520520
});
521521
});
522522
});

0 commit comments

Comments
 (0)