Skip to content

Hide parent popover panel when opening nested popover panel. #1863

Answered by nxnxu
nxnxu asked this question in Help
Discussion options

You must be logged in to vote

I used open render prop on parent to solve this.

function MyPopover() {
  const items = ["Analytics", "Engagement", "Security", "Integrations"];
  const [hide, setHide] = useState(false);

  return (
    <Popover className={'m-4 relative p-2 bg-red-400'}>
      {({ open }) => {
        if (!open)
          setTimeout(() => setHide(false));
        return <>
          <Popover.Button>Parent</Popover.Button>
          <Popover.Panel className={classNames("absolute top-10 z-10 bg-cyan-400 p-2", { "invisible": hide })}>
            {items.map((item, index) => (
              <Popover key={index}>
                <Popover.Button onClick={() => setHide(true)}>{`Child Popover ${index}`}</Popover.B…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nxnxu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant