Make portal optional on dialog, don't use within another dialog

This commit is contained in:
Patrick O'Sullivan 2023-03-09 16:06:41 -06:00
parent d669ead35c
commit ca56841842
2 changed files with 21 additions and 6 deletions

View File

@ -102,7 +102,7 @@ export const AppInfo: FC<AppInfoProps> = ({
</PillButton>
)}
{installStatus !== 'installed' && (
<Dialog>
<Dialog portal={false}>
<DialogTrigger asChild>
<PillButton variant="alt-primary" disabled={installing}>
{installing ? (

View File

@ -3,16 +3,31 @@ import * as DialogPrimitive from '@radix-ui/react-dialog';
import type * as Polymorphic from '@radix-ui/react-polymorphic';
import classNames from 'classnames';
export const Dialog: FC<DialogPrimitive.DialogProps> = ({
export type DialogProps = Polymorphic.Merge<
Polymorphic.OwnProps<typeof DialogPrimitive.Root>,
{
portal?: boolean;
}
>;
export const Dialog: FC<DialogProps> = ({
children,
portal = true,
...props
}) => {
return (
<DialogPrimitive.Root {...props}>
<DialogPrimitive.Portal>
<DialogPrimitive.Overlay className="fixed top-0 bottom-0 left-0 right-0 z-30 transform-gpu bg-black opacity-30" />
{children}
</DialogPrimitive.Portal>
{portal ? (
<DialogPrimitive.Portal>
<DialogPrimitive.Overlay className="fixed top-0 bottom-0 left-0 right-0 z-30 transform-gpu bg-black opacity-30" />
{children}
</DialogPrimitive.Portal>
) : (
<>
<DialogPrimitive.Overlay className="fixed top-0 bottom-0 left-0 right-0 z-30 transform-gpu bg-black opacity-30" />
{children}
</>
)}
</DialogPrimitive.Root>
);
};