Skip to content

Commit

Permalink
fix: Trigger popupMotion leavedClassName order (#219)
Browse files Browse the repository at this point in the history
* fix: Order

* fix: Trigger leaved motion name order
  • Loading branch information
zombieJ authored Nov 9, 2020
1 parent 512e8c4 commit caf84b4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Popup/PopupInner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(

// ======================== 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();
Expand All @@ -143,7 +143,7 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
});

function onShowPrepare() {
return new Promise((resolve) => {
return new Promise(resolve => {
prepareResolveRef.current = resolve;
});
}
Expand Down Expand Up @@ -188,11 +188,11 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
<CSSMotion
visible={visible}
ref={elementRef}
leavedClassName={`${prefixCls}-hidden`}
{...motion}
onAppearPrepare={onShowPrepare}
onEnterPrepare={onShowPrepare}
removeOnLeave={destroyPopupOnHide}
leavedClassName={`${prefixCls}-hidden`}
>
{({ className: motionClassName, style: motionStyle }, motionRef) => {
const mergedClassName = classNames(
Expand Down
24 changes: 24 additions & 0 deletions tests/motion.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<Trigger
action={['click']}
popupAlign={placementAlignMap.left}
popup={<strong className="x-content" />}
popupMotion={{
motionName: 'bamboo',
leavedClassName: 'light',
}}
>
<div className="target">click</div>
</Trigger>,
);

wrapper.trigger();

expect(wrapper.find('CSSMotion').props().leavedClassName).toEqual('light');

wrapper.unmount();
});
});

0 comments on commit caf84b4

Please sign in to comment.