Skip to content

Commit 7f557dc

Browse files
authored
Merge 2e8843c into 4bf8568
2 parents 4bf8568 + 2e8843c commit 7f557dc

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/SubMenu/PopupTrigger.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,18 @@ export default function PopupTrigger({
6262
const popupPlacement = popupPlacementMap[mode];
6363

6464
const targetMotion = getMotion(mode, motion, defaultMotions);
65+
const targetMotionRef = React.useRef(targetMotion);
66+
67+
if (mode !== 'inline') {
68+
/**
69+
* PopupTrigger is only used for vertical and horizontal types.
70+
* When collapsed is unfolded, the inline animation will destroy the vertical animation.
71+
*/
72+
targetMotionRef.current = targetMotion;
73+
}
6574

6675
const mergedMotion: CSSMotionProps = {
67-
...targetMotion,
76+
...targetMotionRef.current,
6877
leavedClassName: `${prefixCls}-hidden`,
6978
removeOnLeave: false,
7079
motionAppear: true,

tests/Menu.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,22 @@ describe('Menu', () => {
574574
rerender(genMenu({ mode: 'vertical' }));
575575
expect(global.triggerProps.popupMotion.motionName).toEqual('bambooLight');
576576
});
577+
578+
it('inline does not affect vertical motion', () => {
579+
const genMenu = props => (
580+
<Menu defaultMotions={defaultMotions} {...props}>
581+
<SubMenu key="bamboo">
582+
<MenuItem key="light" />
583+
</SubMenu>
584+
</Menu>
585+
);
586+
587+
const { rerender } = render(genMenu({ mode: 'vertical' }));
588+
rerender(genMenu({ mode: 'inline' }));
589+
expect(global.triggerProps.popupMotion.motionName).toEqual(
590+
'defaultMotion',
591+
);
592+
});
577593
});
578594

579595
it('onMouseEnter should work', () => {

0 commit comments

Comments
 (0)