diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index f917021e9f..72d2d0d652 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -76,6 +76,7 @@ export interface ModalProps { keyboard?: boolean; wrapProps?: any; prefixCls?: string; + closeIcon?: React.ReactNode; } type getContainerFunc = () => HTMLElement; @@ -164,6 +165,7 @@ export default class Modal extends React.Component { footer: PropTypes.node, title: PropTypes.node, closable: PropTypes.bool, + closeIcon: PropTypes.node, }; handleCancel = (e: React.MouseEvent) => { @@ -210,6 +212,7 @@ export default class Modal extends React.Component { wrapClassName, centered, getContainer, + closeIcon, ...restProps } = this.props; @@ -220,7 +223,7 @@ export default class Modal extends React.Component { ); - const closeIcon = ( + const closeIconToRender = closeIcon || ( @@ -236,7 +239,7 @@ export default class Modal extends React.Component { visible={visible} mousePosition={mousePosition} onClose={this.handleCancel} - closeIcon={closeIcon} + closeIcon={closeIconToRender} /> ); }; diff --git a/components/modal/__tests__/Modal.test.js b/components/modal/__tests__/Modal.test.js index e7e7476879..c96379deec 100644 --- a/components/modal/__tests__/Modal.test.js +++ b/components/modal/__tests__/Modal.test.js @@ -57,4 +57,9 @@ describe('Modal', () => { wrapper.handleOk(); expect(onOk).toHaveBeenCalled(); }); + + it('support closeIcon', () => { + const wrapper = mount(closeIcon} visible />); + expect(wrapper.render()).toMatchSnapshot(); + }); }); diff --git a/components/modal/__tests__/__snapshots__/Modal.test.js.snap b/components/modal/__tests__/__snapshots__/Modal.test.js.snap index 1a2016c324..1f95fed6bd 100644 --- a/components/modal/__tests__/__snapshots__/Modal.test.js.snap +++ b/components/modal/__tests__/__snapshots__/Modal.test.js.snap @@ -169,3 +169,71 @@ exports[`Modal render without footer 1`] = ` `; + +exports[`Modal support closeIcon 1`] = ` +
+
+