popup menu - fix popup placement

This commit is contained in:
Jan Prochazka 2020-12-03 09:36:29 +01:00
parent 327f2140cf
commit 836f48c810

View File

@ -174,7 +174,15 @@ export function ContextMenu({ left, top, children }) {
await sleep(0);
hideMenu();
});
return <ContextMenuStyled style={{ left: `${left}px`, top: `${top}px` }}>{children}</ContextMenuStyled>;
const menuRef = React.useRef(null);
React.useEffect(() => {
if (menuRef.current) fixPopupPlacement(menuRef.current);
}, [menuRef.current]);
return (
<ContextMenuStyled ref={menuRef} style={{ left: `${left}px`, top: `${top}px` }}>
{children}
</ContextMenuStyled>
);
}
// export class ContextMenu extends React.Component<IContextMenuProps> {