Skip to content

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

@kirilledelman

Description

@kirilledelman

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions