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(); }); });