Skip to content

Commit

Permalink
fix(Menu): 修复展开子菜单收起的时候没有动画 #774 (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuilanxin committed Apr 18, 2022
1 parent 270fd2b commit b35cd34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/react-menu/src/SubMenu.tsx
Expand Up @@ -103,6 +103,9 @@ export const SubMenu = React.forwardRef(function <Tag extends TagType = 'a'>(
}
function onEntered(node: HTMLElement) {
node.style.height = 'initial';
if (popupRef.current && popupRef.current.overlayDom) {
node.style.height = popupRef.current.overlayDom.current!.getBoundingClientRect().height + 'px';
}
}

if (!collapse) {
Expand Down
2 changes: 2 additions & 0 deletions packages/react-overlay-trigger/src/index.tsx
Expand Up @@ -72,6 +72,7 @@ const normalizeDelay = (delay?: Delay) => (delay && typeof delay === 'object' ?
export type OverlayTriggerRef = {
hide: () => void;
show: () => void;
overlayDom: React.MutableRefObject<HTMLElement | undefined>;
};

export default React.forwardRef<OverlayTriggerRef, OverlayTriggerProps>((props, ref) => {
Expand Down Expand Up @@ -114,6 +115,7 @@ export default React.forwardRef<OverlayTriggerRef, OverlayTriggerProps>((props,
useImperativeHandle(ref, () => ({
hide: () => hide(),
show: () => show(),
overlayDom: popupRef,
}));

const child: any = React.Children.only(children);
Expand Down

0 comments on commit b35cd34

Please sign in to comment.