fix(chat): anchor the More popover outside the tooltip chain (#1862)
Nested inside TooltipTrigger as-child, PopoverTrigger's PopperAnchor ref resolved to a component object instead of the button, so the popover never became positioned and its content stayed parked off-screen at translate(0, -200%): the menu opened in state only, invisible to the user. Wrapping the tooltip in an explicit PopoverAnchor makes the anchor the real button element, so the menu renders beside it. The tooltip (accessible name More), the menu items, and the rename/branch dialog are unchanged. Adds ui/test/chat-more-menu.test.ts, a browser behaviour check (vite dev server + headless Chrome over CDP, API mocked in-page) that fails on the old nesting with the menu at (0, -526) and passes with it in the viewport; it skips when no Chrome binary is installed.
This commit is contained in:
2 files changed
+355
-15
No files matched your search
@@ -16,6 +16,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import {
|
||||
Popover,
|
||||
PopoverAnchor,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
@@ -100,21 +101,27 @@ function submitPrompt(): void {
|
||||
|
||||
<template>
|
||||
<Popover v-model:open="open">
|
||||
<Tooltip>
|
||||
<TooltipTrigger as-child>
|
||||
<PopoverTrigger as-child>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
class="flex-none"
|
||||
aria-label="More"
|
||||
>
|
||||
<Ellipsis />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>More</TooltipContent>
|
||||
</Tooltip>
|
||||
<!-- The anchor sits outside the tooltip chain on purpose: nested inside
|
||||
TooltipTrigger, the popper anchor ref resolves to a component object
|
||||
rather than the button, the content is never positioned, and the menu
|
||||
stays parked off-screen. -->
|
||||
<PopoverAnchor as-child>
|
||||
<Tooltip>
|
||||
<TooltipTrigger as-child>
|
||||
<PopoverTrigger as-child>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
class="flex-none"
|
||||
aria-label="More"
|
||||
>
|
||||
<Ellipsis />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>More</TooltipContent>
|
||||
</Tooltip>
|
||||
</PopoverAnchor>
|
||||
<PopoverContent align="end" class="grid w-64 gap-0.5 p-1">
|
||||
<template v-if="currentSession">
|
||||
<Button
|
||||
|
||||
Reference in new issue
Block a user