Prevent profile popover from reopening on panel click

Use the popover as a hover anchor so clicking an avatar opens the profile panel without toggling the hover card back open.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Thomas Petersen
2026-05-06 15:38:51 -04:00
parent 4188f31326
commit 65da46dd2b
2 changed files with 7 additions and 5 deletions

View File

@@ -13,7 +13,7 @@ import { rewriteRelayUrl } from "@/shared/lib/mediaUrl";
import { useAgentSession } from "@/shared/context/AgentSessionContext";
import { useProfilePanel } from "@/shared/context/ProfilePanelContext";
import { Popover, PopoverContent, PopoverTrigger } from "@/shared/ui/popover";
import { Popover, PopoverAnchor, PopoverContent } from "@/shared/ui/popover";
import { BotIdenticon } from "@/features/messages/ui/BotIdenticon";
type UserProfilePopoverProps = {
@@ -135,7 +135,7 @@ export function UserProfilePopover({
return (
<Popover onOpenChange={setOpen} open={open}>
<PopoverTrigger asChild>
<PopoverAnchor asChild>
{/* biome-ignore lint/a11y/useSemanticElements: wrapper div for hover/click behavior */}
<div
role="button"
@@ -156,7 +156,7 @@ export function UserProfilePopover({
>
{children}
</div>
</PopoverTrigger>
</PopoverAnchor>
<PopoverContent
align="start"
className="w-80"

View File

@@ -157,11 +157,13 @@ test("hovering avatar opens popover, clicking opens profile panel", async ({
// Hover should open the popover
await avatarButton.hover();
const profilePopover = page.getByTestId("user-profile-popover");
const profilePopover = page.locator(
'[data-testid="user-profile-popover"][data-state="open"]',
);
await expect(profilePopover).toBeVisible();
// Click should close the popover and open the profile panel
await avatarButton.click();
await expect(profilePopover).not.toBeVisible();
await expect(profilePopover).toHaveCount(0);
await expect(page.getByTestId("user-profile-panel")).toBeVisible();
});