Closed anthonyissa closed 4 months ago
<SheetTrigger className="md:hidden" asChild>
<Menu />
</SheetTrigger>
This is the trigger button
Hey,
Don't know if its the full code of your header or if you are cleaning things to keep the issue clear.
But small warning on something I found out some days ago : when you have an element that trigger a Sheet inside another Element that uses React Portal
(like Popover), things can be broken: the easy work around is to add a useState and connect it to your sheet and Popover open={open} and onOpenChange={setOpen}
.
Then => close the Popover manually => Open the Sheet Manually.
export const SidePanel = ({ title, isOpen, setIsOpen, children }: SidePanelProps) => {
return (
<Sheet open={isOpen} onOpenChange={setIsOpen}>
<SheetContent>
<SheetHeader>
<SheetTitle>{title}</SheetTitle>
<SheetDescription>
<div className={'flex flex-col gap-y-2'}>
{children}
</div>
</SheetDescription>
</SheetHeader>
</SheetContent>
</Sheet>
)
}
from: https://www.radix-ui.com/docs/primitives/components/dialog#close-after-asynchronous-form-submission
Hey,
Don't know if its the full code of your header or if you are cleaning things to keep the issue clear.
But small warning on something I found out some days ago : when you have an element that trigger a Sheet inside another Element that uses
React Portal
(like Popover), things can be broken: the easy work around is to add a useState and connect it to your sheet and Popoveropen={open} and onOpenChange={setOpen}
.Then => close the Popover manually => Open the Sheet Manually.
export const SidePanel = ({ title, isOpen, setIsOpen, children }: SidePanelProps) => { return ( <Sheet open={isOpen} onOpenChange={setIsOpen}> <SheetContent> <SheetHeader> <SheetTitle>{title}</SheetTitle> <SheetDescription> <div className={'flex flex-col gap-y-2'}> {children} </div> </SheetDescription> </SheetHeader> </SheetContent> </Sheet> ) }
from: https://www.radix-ui.com/docs/primitives/components/dialog#close-after-asynchronous-form-submission
it doesn't work and crashes the NextJS application
This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.
Some things to note:
npx shadcn-ui add sheet
didn't install@radix-ui/react-dialog
needed in sheet.tsx. I think this might be linked to radix-ui because every component linked to radix isn't working.package.json
header.tsx