From 6998f66eb5595d83e36131704c921dad35420301 Mon Sep 17 00:00:00 2001 From: Hughen <446370503@163.com> Date: Fri, 9 Mar 2018 15:02:13 +0800 Subject: [PATCH] feat: add afterClose to Alert (#9448) - add afterClose to Alert, in in order to achieve smoothly unmount. --- .../__tests__/__snapshots__/demo.test.js.snap | 28 +++++++++++ components/alert/demo/smooth-closed.md | 48 +++++++++++++++++++ components/alert/index.tsx | 3 ++ 3 files changed, 79 insertions(+) create mode 100644 components/alert/demo/smooth-closed.md diff --git a/components/alert/__tests__/__snapshots__/demo.test.js.snap b/components/alert/__tests__/__snapshots__/demo.test.js.snap index d10aa94677..f75929f603 100644 --- a/components/alert/__tests__/__snapshots__/demo.test.js.snap +++ b/components/alert/__tests__/__snapshots__/demo.test.js.snap @@ -366,6 +366,34 @@ exports[`renders ./components/alert/demo/icon.md correctly 1`] = ` `; +exports[`renders ./components/alert/demo/smooth-closed.md correctly 1`] = ` +
+
+ + Alert Message Text + + + + + +
+

+ placeholder text here +

+
+`; + exports[`renders ./components/alert/demo/style.md correctly 1`] = `
{ + this.setState({ visiable: false }); + } + render() { + return ( +
+ { + this.state.visiable ? ( + + ) : null + } +

placeholder text here

+
+ ); + } +} + +ReactDOM.render( + +, mountNode); +```` diff --git a/components/alert/index.tsx b/components/alert/index.tsx index 6893618f5d..bd93a2aca0 100755 --- a/components/alert/index.tsx +++ b/components/alert/index.tsx @@ -21,6 +21,8 @@ export interface AlertProps { description?: React.ReactNode; /** Callback when close Alert */ onClose?: React.MouseEventHandler; + /** Trigger when animation ending of Alert */ + afterClose?: Function; /** Whether to show icon */ showIcon?: boolean; iconType?: string; @@ -56,6 +58,7 @@ export default class Alert extends React.Component { closed: true, closing: true, }); + (this.props.afterClose || noop)(); } render() { let {