Skip to content

Commit

Permalink
fix(Overlay): 修复问题CSSTransition传递nodeRef后各回调没有node问题 #769 (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
nullptr-z committed Apr 15, 2022
1 parent e4716ec commit 305541d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 5 additions & 5 deletions packages/react-menu/src/SubMenu.tsx
Expand Up @@ -88,21 +88,21 @@ export const SubMenu = React.forwardRef(function <Tag extends TagType = 'a'>(
}
}
function onExit(node: HTMLElement) {
node && (node.style.height = `${node.scrollHeight}px`);
node.style.height = `${node.scrollHeight}px`;
setIsOpen(false);
}
function onExiting(node: HTMLElement) {
node && (node.style.height = '0px');
node.style.height = '0px';
}
function onEnter(node: HTMLElement) {
node && (node.style.height = '1px');
node.style.height = '1px';
setIsOpen(true);
}
function onEntering(node: HTMLElement) {
node && (node.style.height = `${node.scrollHeight}px`);
node.style.height = `${node.scrollHeight}px`;
}
function onEntered(node: HTMLElement) {
node && (node.style.height = 'initial');
node.style.height = 'initial';
}

if (!collapse) {
Expand Down
14 changes: 11 additions & 3 deletions packages/react-overlay/src/index.tsx
Expand Up @@ -57,6 +57,10 @@ export default function Overlay(props: OverlayProps) {
onClosed = noop,
onClose = noop,
onEnter = noop,
onExiting = noop,
onEntering = noop,
onEntered = noop,
onExit = noop,
children,
dialogProps = {},
...otherProps
Expand Down Expand Up @@ -135,20 +139,24 @@ export default function Overlay(props: OverlayProps) {
unmountOnExit={unmountOnExit}
timeout={timeout!}
in={isOpen}
onEnter={(_, isAppearing) => {
onEnter={(isAppearing: boolean) => {
onEnter(overlay.current!, isAppearing);
}}
onEntering={(_, isAppearing) => {
onEntering={(isAppearing: boolean) => {
onOpening(overlay.current!, isAppearing);
onEntering(overlay.current!);
}}
onEntered={(_, isAppearing) => {
onEntered={(isAppearing: boolean) => {
onOpened(overlay.current!, isAppearing);
onEntered(overlay.current!);
}}
onExiting={() => {
onClosing(overlay.current!);
onExiting(overlay.current!);
}}
onExited={() => {
handleClosed(overlay.current!);
onExit(overlay.current!);
}}
nodeRef={overlay}
{...otherProps}
Expand Down

0 comments on commit 305541d

Please sign in to comment.