shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
64.35k stars 3.65k forks source link

[bug]: HoverCard Trigger is Focused on Drawer Opening (HoverCardContent being displayed on Drawer Open) #3989

Open geudrik opened 1 month ago

geudrik commented 1 month ago

Describe the bug

When I use a drawer with a popover (with a button as a trigger element), it's getting focus when the drawer opens (meaning the popover is displayed on drawer open). This shouldn't be the case.

Affected component/components

Drawer, Button, Hover Card

How to reproduce

  1. Create a drawer that's openable with a button click (or whatever)
  2. Add a Hover Card, with a Button as a a HoverCardTrigger
  3. Open the drawer - it will be focused, and the Hover Card will be displayed
// Icon is an Icon from lucide-react
    <HoverCard openDelay={300}>
        <HoverCardTrigger asChild>
            <Button variant="link"><Icon style={{width: 20, height: 20}}/></Button>
        </HoverCardTrigger>
        <HoverCardContent className="w-80">
            <div className="flex justify-between space-x-4">
                <span className="relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full">
                    <Icon className={"aspect-square h-full w-full"}/>
                </span>
                <div className="space-y-1">
                    <h4 className="text-sm font-semibold text-destructive">{visibility}
                    </h4>
                    <p className="text-sm">
                        {obj.description}
                    </p>
                </div>
            </div>
        </HoverCardContent>
    </HoverCard>

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

OSX, Arc (Chromium), NextJS+Shad

Before submitting

dkDevHub commented 3 weeks ago

I also faced this bug with frezzes drawer on ios, how i can fix it?