From caf84b436bf0a907de341a8e6605335f7d29d23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Mon, 9 Nov 2020 18:31:42 +0800 Subject: [PATCH] fix: Trigger popupMotion leavedClassName order (#219) * fix: Order * fix: Trigger leaved motion name order --- src/Popup/PopupInner.tsx | 6 +++--- tests/motion.test.jsx | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Popup/PopupInner.tsx b/src/Popup/PopupInner.tsx index e512d5f3..f077372a 100644 --- a/src/Popup/PopupInner.tsx +++ b/src/Popup/PopupInner.tsx @@ -134,7 +134,7 @@ const PopupInner = React.forwardRef( // ======================== Motion ======================== const motion = { ...getMotion(props) }; - ['onAppearEnd', 'onEnterEnd', 'onLeaveEnd'].forEach((eventName) => { + ['onAppearEnd', 'onEnterEnd', 'onLeaveEnd'].forEach(eventName => { const originHandler: MotionEndEventHandler = motion[eventName]; motion[eventName] = (element, event) => { goNextStatus(); @@ -143,7 +143,7 @@ const PopupInner = React.forwardRef( }); function onShowPrepare() { - return new Promise((resolve) => { + return new Promise(resolve => { prepareResolveRef.current = resolve; }); } @@ -188,11 +188,11 @@ const PopupInner = React.forwardRef( {({ className: motionClassName, style: motionStyle }, motionRef) => { const mergedClassName = classNames( diff --git a/tests/motion.test.jsx b/tests/motion.test.jsx index a4f5f2e1..033c2669 100644 --- a/tests/motion.test.jsx +++ b/tests/motion.test.jsx @@ -28,5 +28,29 @@ describe('Trigger.Motion', () => { wrapper.trigger(); expect(wrapper.getPopupInner().hasClass('bamboo-appear')).toBeTruthy(); + + wrapper.unmount(); + }); + + it('use correct leave motion', () => { + const wrapper = mount( + } + popupMotion={{ + motionName: 'bamboo', + leavedClassName: 'light', + }} + > +
click
+
, + ); + + wrapper.trigger(); + + expect(wrapper.find('CSSMotion').props().leavedClassName).toEqual('light'); + + wrapper.unmount(); }); });