Skip to content
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

[BUG] - Can't trigger popover with tooltop button #1265

Closed
nguyen227 opened this issue Aug 4, 2023 · 1 comment
Closed

[BUG] - Can't trigger popover with tooltop button #1265

nguyen227 opened this issue Aug 4, 2023 · 1 comment
Labels
🐛 Type: Bug Something isn't working

Comments

@nguyen227
Copy link

Describe the bug

I want to open a popover through a button with helper text (tooltip). But when I click on the trigger button, it doesn't open the popover. It works fine when I remove the Tooltip component, but it won't work as I expect.

Your Example Website or App

https://codesandbox.io/p/sandbox/autumn-cloud-knwv73?file=%2FApp.jsx%3A6%2C47&utm_medium=sandpack

Steps to Reproduce the Bug or Issue

Just run the code example in ref link

Expected behavior

Open the popover content when click on a tooltip button

Screenshots or Videos

No response

Operating System Version

Windows 11

Browser

Chrome

@nguyen227 nguyen227 added the 🐛 Type: Bug Something isn't working label Aug 4, 2023
@nguyen227 nguyen227 changed the title [BUG] - CAN'T TRIGGER POPOVER WITH TOOLTIP [BUG] - Can't trigger popover with tooltop button Aug 4, 2023
@jrgarciadev
Copy link
Member

jrgarciadev commented Aug 5, 2023

Hey @nguyen227

Tooltip and Popover cannot share the same DOM element as trigger element.

A workaround is to add an extra element inside the Tooltip. Keep in mind that the focus state will be handled differently.

    <Popover placement="top" showArrow={true}>
      <Tooltip content="Help text">
        {/* extra element */}
        <div className="max-w-fit">
          <PopoverTrigger>
            <Button>Open Popover</Button>
          </PopoverTrigger>
        </div>
      </Tooltip>
      <PopoverContent>
        <div className="px-1 py-2">
          <div className="text-small font-bold">Popover Content</div>
          <div className="text-tiny">This is the popover content</div>
        </div>
      </PopoverContent>
    </Popover>

See this Codesanbox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants