nextui icon indicating copy to clipboard operation
nextui copied to clipboard

[BUG] - Controlled Popover can't be dismissed by clicking outside, if opened via isOpen prop

Open kirilledelman opened this issue 6 months ago • 2 comments

HeroUI Version

2.8.5

Describe the bug

I needed to be able to open popover from a different spot as well as from the trigger button, and I discovered that opening it via isOpen prop makes it impossible to close it by clicking on the backdrop when Popover's backdrop is set to "opaque".

I tried adding shouldCloseOnInteractOutside callback to try and force it to work, but it never gets called in this case.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

Minimal code illustrating this behavior:

const [isOpen, setIsOpen] = useState(false);
return <>
<Button onPress={()=>setIsOpen(true)}>Open Controllably</Button>
<Popover isOpen={isOpen} onOpenChange={setIsOpen} 
		shouldCloseOnInteractOutside={()=>true}
		backdrop="opaque">
	<PopoverTrigger>
		<Button>Open with Trigger</Button>
	</PopoverTrigger>
	<PopoverContent>
		Click outside to close
	</PopoverContent>
</Popover></>;

Expected behavior

Expecting the popover to be dismissed by clicking on the backdrop.

Screenshots or Videos

No response

Operating System Version

MacOS

Browser

Chrome

kirilledelman avatar Oct 30 '25 17:10 kirilledelman

ENG-2865

linear[bot] avatar Oct 30 '25 17:10 linear[bot]

For anyone who needs this to work, I found that adding onClick to Popover, that closes it DOES WORK.

kirilledelman avatar Oct 31 '25 13:10 kirilledelman