Skip to content

Commit caf84b4

Browse files
authored
fix: Trigger popupMotion leavedClassName order (#219)
* fix: Order * fix: Trigger leaved motion name order
1 parent 512e8c4 commit caf84b4

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/Popup/PopupInner.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
134134

135135
// ======================== Motion ========================
136136
const motion = { ...getMotion(props) };
137-
['onAppearEnd', 'onEnterEnd', 'onLeaveEnd'].forEach((eventName) => {
137+
['onAppearEnd', 'onEnterEnd', 'onLeaveEnd'].forEach(eventName => {
138138
const originHandler: MotionEndEventHandler = motion[eventName];
139139
motion[eventName] = (element, event) => {
140140
goNextStatus();
@@ -143,7 +143,7 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
143143
});
144144

145145
function onShowPrepare() {
146-
return new Promise((resolve) => {
146+
return new Promise(resolve => {
147147
prepareResolveRef.current = resolve;
148148
});
149149
}
@@ -188,11 +188,11 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
188188
<CSSMotion
189189
visible={visible}
190190
ref={elementRef}
191+
leavedClassName={`${prefixCls}-hidden`}
191192
{...motion}
192193
onAppearPrepare={onShowPrepare}
193194
onEnterPrepare={onShowPrepare}
194195
removeOnLeave={destroyPopupOnHide}
195-
leavedClassName={`${prefixCls}-hidden`}
196196
>
197197
{({ className: motionClassName, style: motionStyle }, motionRef) => {
198198
const mergedClassName = classNames(

tests/motion.test.jsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,29 @@ describe('Trigger.Motion', () => {
2828

2929
wrapper.trigger();
3030
expect(wrapper.getPopupInner().hasClass('bamboo-appear')).toBeTruthy();
31+
32+
wrapper.unmount();
33+
});
34+
35+
it('use correct leave motion', () => {
36+
const wrapper = mount(
37+
<Trigger
38+
action={['click']}
39+
popupAlign={placementAlignMap.left}
40+
popup={<strong className="x-content" />}
41+
popupMotion={{
42+
motionName: 'bamboo',
43+
leavedClassName: 'light',
44+
}}
45+
>
46+
<div className="target">click</div>
47+
</Trigger>,
48+
);
49+
50+
wrapper.trigger();
51+
52+
expect(wrapper.find('CSSMotion').props().leavedClassName).toEqual('light');
53+
54+
wrapper.unmount();
3155
});
3256
});

0 commit comments

Comments
 (0)