Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[popover2] feat(ContextMenu2): support popoverProps.rootBoundary #5423

Merged
merged 8 commits into from
Aug 11, 2022
Next Next commit
[popover2] fix: wrong position when ContextMenu2 invoked from Drawer
GalvinGao committed Jul 9, 2022
commit ff8122fa1c51a857d4f876522828e520a80d8d2d
10 changes: 6 additions & 4 deletions packages/popover2/src/contextMenu2.tsx
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ export interface ContextMenu2Props
* A limited subset of props to forward along to the popover generated by this component.
*/
popoverProps?: IOverlayLifecycleProps &
Pick<Popover2Props, "popoverClassName" | "transitionDuration" | "popoverRef">;
Pick<Popover2Props, "popoverClassName" | "transitionDuration" | "popoverRef" | "rootBoundary">;

/**
* HTML tag to use for container element. Only used if this component's children are specified as
@@ -129,11 +129,13 @@ export const ContextMenu2: React.FC<ContextMenu2Props> = React.forwardRef<any, C
content,
disabled = false,
onContextMenu,
popoverProps,
popoverProps = {},
tagName = "div",
...restProps
} = props;

const { rootBoundary = "viewport", ...popoverPropsRest } = popoverProps;

// ancestor Tooltip2Context state doesn't affect us since we don't care about parent ContextMenu2s, we only want to
// force disable parent Tooltip2s in certain cases through dispatching actions
// N.B. any calls to this dispatch function will be no-ops if there is no Tooltip2Provider ancestor of this component
@@ -185,7 +187,7 @@ export const ContextMenu2: React.FC<ContextMenu2Props> = React.forwardRef<any, C
const maybePopover =
menu === undefined ? undefined : (
<Popover2
{...popoverProps}
{...popoverPropsRest}
content={
// this prevents right-clicking inside our context menu
<div onContextMenu={cancelContextMenu}>{menu}</div>
@@ -204,7 +206,7 @@ export const ContextMenu2: React.FC<ContextMenu2Props> = React.forwardRef<any, C
})}
placement="right-start"
positioningStrategy="fixed"
rootBoundary="viewport"
rootBoundary={rootBoundary}
renderTarget={renderTarget}
transitionDuration={popoverProps?.transitionDuration ?? 100}
/>