diff --git a/src/renderer/components/menu/menu.tsx b/src/renderer/components/menu/menu.tsx index 5e070698dd..049d80c35c 100644 --- a/src/renderer/components/menu/menu.tsx +++ b/src/renderer/components/menu/menu.tsx @@ -5,7 +5,6 @@ import { createPortal } from "react-dom"; import { autobind, cssNames, noop } from "../../utils"; import { Animate } from "../animate"; import { Icon, IconProps } from "../icon"; -import debounce from "lodash/debounce"; export const MenuContext = React.createContext(null); export type MenuContextValue = Menu; @@ -122,7 +121,7 @@ export class Menu extends React.Component { } } - refreshPosition = debounce(() => { + refreshPosition = () => { if (!this.props.usePortal || !this.opener) return; const { width, height } = this.opener.getBoundingClientRect(); let { left, top, bottom, right } = this.opener.getBoundingClientRect(); @@ -157,7 +156,7 @@ export class Menu extends React.Component { delete position.bottom; } this.setState({ position }); - }, Animate.VISIBILITY_DELAY_MS); + }; open() { if (this.isOpen) return; @@ -248,6 +247,10 @@ export class Menu extends React.Component { } render() { + if (this.isOpen) { + setImmediate(() => this.refreshPosition()); + } + const { position, id } = this.props; let { className, usePortal } = this.props;