import type { JSX } from "@solidjs/web";
/**
* `
` — moves the popup subtree to a different part of the DOM
* (by default `document.body`). Mirrors React's `MenuPortal`.
*/
import { Show } from "solid-js";
import type { FloatingPortalTarget } from "../../internals/floating-ui/components/floating-portal";
import { FloatingPortal } from "../../internals/floating-ui/components/floating-portal";
import { useMenuRootContext } from "../root/menu-root-context";
import { MenuPortalContext } from "./menu-portal-context";
export interface MenuPortalProps {
children?: JSX.Element;
/** Whether to keep the portal mounted while the popup is hidden. */
keepMounted?: boolean | undefined;
/** Mount target for the portal. Defaults to `document.body`. */
container?: FloatingPortalTarget;
}
export function MenuPortal(props: MenuPortalProps): JSX.Element {
const root = useMenuRootContext();
const keepMounted = (): boolean => props.keepMounted ?? false;
const shouldRender = (): boolean => root.mounted() || keepMounted();
return (
{props.children}
);
}