fix: always mount popover backdrop portal to prevent remount issues

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
codytseng 2026-03-14 13:33:27 +08:00
parent 330152fd5c
commit e5e0918c93

View file

@ -26,8 +26,8 @@ const Popover = ({
return ( return (
<> <>
{open && {createPortal(
createPortal( open ? (
<div <div
ref={backdropRef} ref={backdropRef}
className="pointer-events-auto fixed inset-0 z-40" className="pointer-events-auto fixed inset-0 z-40"
@ -35,9 +35,10 @@ const Popover = ({
e.stopPropagation() e.stopPropagation()
handleOpenChange(false) handleOpenChange(false)
}} }}
/>, />
document.body ) : null,
)} document.body
)}
<PopoverPrimitive.Root {...props} open={open} onOpenChange={handleOpenChange} modal={false} /> <PopoverPrimitive.Root {...props} open={open} onOpenChange={handleOpenChange} modal={false} />
</> </>
) )