Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

ui: allow setting popup container

Abdullah Atta569f4537e7e0
diff --git a/packages/ui/src/components/menu/index.tsx b/packages/ui/src/components/menu/index.tsx
index c9712bb4b..9ef2fc02f 100644
--- a/packages/ui/src/components/menu/index.tsx
+++ b/packages/ui/src/components/menu/index.tsx
@@ -224,7 +224,7 @@ export type MenuPresenterProps = Omit<
PopupPresenterProps,
"movable" | "scope"
> &
- MenuProps;
+ MenuProps & { container?: HTMLElement };
export function MenuPresenter(props: PropsWithChildren<MenuPresenterProps>) {
const {
items = [],
@@ -234,6 +234,7 @@ export function MenuPresenter(props: PropsWithChildren<MenuPresenterProps>) {
blocking,
focusOnRender,
isMobile,
+ container,
...restProps
} = props;
@@ -261,6 +262,7 @@ export function MenuPresenter(props: PropsWithChildren<MenuPresenterProps>) {
isOpen={isOpen}
onClose={onClose}
blocking={blocking}
+ container={container}
focusOnRender={focusOnRender}
isMobile={isMobile}
>
diff --git a/packages/ui/src/components/popup-presenter/index.tsx b/packages/ui/src/components/popup-presenter/index.tsx
index a34923607..9c2875dd3 100644
--- a/packages/ui/src/components/popup-presenter/index.tsx
+++ b/packages/ui/src/components/popup-presenter/index.tsx
@@ -32,6 +32,7 @@ export type PopupPresenterProps = {
movable?: boolean;
scope?: keyof ThemeScopes;
isMobile?: boolean;
+ container?: HTMLElement;
} & BoxProps;
function _PopupPresenter(props: PropsWithChildren<PopupPresenterProps>) {
@@ -44,6 +45,7 @@ function _PopupPresenter(props: PropsWithChildren<PopupPresenterProps>) {
children,
scope,
isMobile,
+ container,
...restProps
} = props;
@@ -140,7 +142,8 @@ function _PopupPresenter(props: PropsWithChildren<PopupPresenterProps>) {
className={"popup-presenter"}
role="menu"
isOpen={isOpen}
- appElement={document.body}
+ appElement={container || document.body}
+ parentSelector={() => container || document.body}
shouldCloseOnEsc
shouldReturnFocusAfterClose
shouldCloseOnOverlayClick
@@ -150,6 +153,7 @@ function _PopupPresenter(props: PropsWithChildren<PopupPresenterProps>) {
onRequestClose={onClose}
portalClassName={"popup-presenter-portal"}
onAfterOpen={(obj) => {
+ Modal.setAppElement(container || document.body);
if (!obj || !position) return;
repositionPopup(position);