-
Notifications
You must be signed in to change notification settings - Fork 872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Popover opened inside a Dialog closes immediately under certain circumstances #2348
Comments
It looks like to be #2180. Upgrade to RC version should work |
@joaom00, any idea when the official release will be? |
Not sure |
@leofavre facing the same issue too – looks like downgrading to |
Hey @steven-tey! Have you tested this fix on Safari? We are having the same issue with popovers and dialogs with safari browsers in open-sauced/app#1144. Chrome and firefox works as expected. Thanks in advance 🙏 |
We have this problem also. Implemented an ugly temporary fix by using a cooldown like this: const [cooldown, setCooldown] = useState(false);
const [open, setOpen] = useState(false);
function handleSet() {
if (cooldown) return;
console.log(‘rex’);
setOpen(!open);
setCooldown(true);
setTimeout(() => {
setCooldown(false);
}, 200);
} |
Can confirm that the fix from @CarelessCourage works as well! Ended up needing to upgrade |
Am seeing this as well. In our case we have an onclick handler inside a |
@nzjoel1234 I had the same problem and for me setting modal=true on popover fix this. function StatusItem({ status }: StatusItemProps) {
const [openChangeColor, setOpenChangeColor] = useState(false);
return (
<div className="border bg-body-background md:bg-background h-16 rounded-[20px] px-7 flex flex-row items-center shrink-0">
<Popover
open={openChangeColor}
onOpenChange={setOpenChangeColor}
modal={true}
>
<PopoverAnchor>
<div
className="w-[15px] h-[15px] rounded-full mx-4"
style={{ backgroundColor: status.color }}
/>
</PopoverAnchor>
<PopoverContent>Color Picker</PopoverContent>
</Popover>
<span className="text-foreground font-medium text-sm">{status.name}</span>
<div className="flex-grow flex-1"></div>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<button type="button" className="outline-none">
<MoreVertical className="h-[18px] w-[18px] text-gray1" />
</button>
</DropdownMenuTrigger>
<DropdownMenuContent className="md:w-52">
<DropdownMenuItem>
<Pencil className="mr-[10px] h-5 w-5" />
<span>Change Name</span>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => setOpenChangeColor(true)}>
<Palette className="mr-[10px] h-5 w-5" />
<span>Change Color</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
);
} |
Running into this as well, but haven't yet been able to figure our a workaround that works for us. |
My issue was caused by the fact that closing the Since the To resolve this I added the following:
|
Thanks!! For me working in both browsers firefox and chrome |
Same happened for me. I have a popover command dropdown UX inside an alert dialog. <AlertDialog... and basically my popover was auto closing. Solution is to set @nzjoel1234's solution worked but then triggered infinite recursion like #2390 as something fought over auto-focus. I had to prevent that by stopping the auto focus on the popover content 🤷♂️. |
Should this be closed? What if one wants to focus inside the popover in a modal? |
Bug report
Current Behavior
A Popover opened inside a Dialog closes immediately when:
@radix-ui/react-dialog
version is 1.0.4;@radix-ui/react-popover
version is 1.0.6;Popover.Trigger
re-renders according to thePopover.Root
state;Popover.Portal
is present;Screen.Recording.2023-08-18.at.13.05.11.mov
Expected behavior
The Popover should stay opened when the trigger is clicked.
Reproducible example
Code Sandbox
Additional context
Your environment
@radix-ui/react-dialog
;@radix-ui/react-popover
The text was updated successfully, but these errors were encountered: