From 32bba3a16ca1d515b5035fef36d40dea28e053f9 Mon Sep 17 00:00:00 2001 From: chengyongru <61816729+chengyongru@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:05:42 +0800 Subject: [PATCH] fix(webui): anchor floating surface animations (#6722) * fix(webui): anchor floating surface animations * test(webui): assert the dispatched file menu click coordinate --- webui/COMPONENTS.md | 2 +- webui/browser/continuity-fixture.tsx | 13 +++++++ webui/browser/continuity.spec.ts | 38 +++++++++++++++++++ webui/browser/overlay-focus.spec.ts | 24 ++++++++++++ webui/src/components/FileActions.tsx | 4 +- .../components/thread/ModelPresetBadge.tsx | 1 - .../src/components/ui/tooltip-primitives.tsx | 2 +- 7 files changed, 80 insertions(+), 4 deletions(-) diff --git a/webui/COMPONENTS.md b/webui/COMPONENTS.md index 9b1615ab9..6533c731f 100644 --- a/webui/COMPONENTS.md +++ b/webui/COMPONENTS.md @@ -62,7 +62,7 @@ Prompt navigation keeps a three-page raw window. Fragmented turns also retain th The application theme remains the single owner for paired day/night artwork. The Sidebar keeps the original daytime mark and uses a sleeping-cap variant in dark mode; the Star invitation pairs matching day/night illustrations. Both layers reserve the same geometry. `.theme-art` blends opacity for System changes and browsers without native snapshots; a native root View Transition owns the whole-frame fade instead. Reduced motion switches artwork directly. Entry and conversation surfaces keep their normal theme colors without decorative ambient glow. -Dropdowns and popovers use Radix's resolved transform origin and side, so motion stays attached to the trigger after collision handling. Radix owns their presence and focus. `SidebarPanel` retains its content until the slot and surface finish their actual exit animations, ignores descendant activity, and cancels teardown when reopened. Closing content is inert and hidden from assistive navigation; callers still own focus restoration. Disclosures keep their existing in-flow height transition and draft retention. +Dropdowns, popovers, and tooltips use Radix's resolved transform origin so scaling stays on the trigger-facing edge after collision handling. The file context menu uses the pointer location or the focused file as its anchor. Surfaces with slide motion use the resolved side. Radix owns their presence and focus. `SidebarPanel` retains its content until the slot and surface finish their actual exit animations, ignores descendant activity, and cancels teardown when reopened. Closing content is inert and hidden from assistive navigation; callers still own focus restoration. Disclosures keep their existing in-flow height transition and draft retention. ## Typography diff --git a/webui/browser/continuity-fixture.tsx b/webui/browser/continuity-fixture.tsx index 91ff059e1..546535c11 100644 --- a/webui/browser/continuity-fixture.tsx +++ b/webui/browser/continuity-fixture.tsx @@ -1,5 +1,6 @@ import { useRef, useState } from "react"; +import { FileActions } from "@/components/FileActions"; import { Button } from "@/components/ui/button"; import { Disclosure } from "@/components/ui/disclosure"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; @@ -7,6 +8,7 @@ import { Input } from "@/components/ui/input"; import { sidePanelSurfaceClassName } from "@/components/ui/floating-surface"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { SidebarPanel } from "@/components/ui/sidebar-panel"; +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; export function ContinuityFixture() { const [open, setOpen] = useState(false); @@ -14,6 +16,17 @@ export function ContinuityFixture() { const close = () => { setOpen(false); trigger.current?.focus(); }; return

Interaction continuity

+
+ + + + Keyboard help + + + + + +
diff --git a/webui/browser/continuity.spec.ts b/webui/browser/continuity.spec.ts index 6b4da722c..53ef649b5 100644 --- a/webui/browser/continuity.spec.ts +++ b/webui/browser/continuity.spec.ts @@ -55,6 +55,44 @@ for (const name of ["Conversation actions", "Quick note"]) { } } +test("a tooltip scales from the trigger-facing edge after flipping", async ({ page }) => { + await page.setViewportSize({ width: 390, height: 720 }); + await page.goto("/browser/fixture.html?case=continuity"); + await page.getByRole("button", { name: "Help", exact: true }).hover(); + const tip = page.locator('[data-side][data-state="delayed-open"]').filter({ hasText: "Keyboard help" }); + await expect(tip).toHaveAttribute("data-side", "bottom"); + await expect(tip).toHaveCSS("transform-origin", /px 0px$/); +}); + +for (const input of ["pointer", "keyboard"]) { + test(`the file menu scales from its ${input} anchor after shifting into the viewport`, async ({ page }) => { + await page.setViewportSize({ width: 390, height: 720 }); + await page.goto("/browser/fixture.html?case=continuity"); + const trigger = page.getByRole("button", { name: "Report file" }); + const bounds = (await trigger.boundingBox())!; + const anchorX = input === "pointer" ? Math.floor(bounds.x + bounds.width - 6) : Math.round(bounds.x); + if (input === "pointer") await page.mouse.click(anchorX, Math.floor(bounds.y + bounds.height / 2), { button: "right" }); + else await trigger.press("Shift+F10"); + const menu = page.getByRole("menu"); + await expect(menu).toHaveAttribute("data-side", "bottom"); + await expect.poll(() => menu.evaluate(node => { + const [x, y] = getComputedStyle(node).transformOrigin.split(" ").map(Number.parseFloat); + return { x: Math.round(node.parentElement!.getBoundingClientRect().left + x), y }; + })).toEqual({ x: anchorX, y: 0 }); + await menu.press("Escape"); + await expect(trigger).toBeFocused(); + }); +} + +test("a tooltip opens without scaling when reduced motion is requested", async ({ page }) => { + await page.emulateMedia({ reducedMotion: "reduce" }); + await page.goto("/browser/fixture.html?case=continuity"); + await page.getByRole("button", { name: "Help", exact: true }).focus(); + const tip = page.locator('[data-side][data-state="instant-open"]').filter({ hasText: "Keyboard help" }); + await expect(tip).toHaveAttribute("data-side", "bottom"); + await expect(tip).toHaveCSS("animation-name", "none"); +}); + test("a sidebar follows its actual exit and preserves an interrupted editor", async ({ page }) => { await page.goto("/browser/fixture.html?case=continuity"); const toggle = page.getByRole("button", { name: "Toggle details", exact: true }); diff --git a/webui/browser/overlay-focus.spec.ts b/webui/browser/overlay-focus.spec.ts index c689cebd7..e46729cde 100644 --- a/webui/browser/overlay-focus.spec.ts +++ b/webui/browser/overlay-focus.spec.ts @@ -53,6 +53,30 @@ test("model picker keyboard Escape returns visible focus to its trigger", async expect(await trigger.evaluate((node) => node.matches(":focus-visible"))).toBe(true); }); +test("the model picker enters from the trigger after flipping below it", async () => { + await page.setViewportSize({ width: 390, height: 720 }); + const trigger = page.getByRole("button", { name: "First model", exact: true }); + // Leave no room above the trigger so the preferred top placement must flip. + await trigger.evaluate(node => Object.assign(node.style, { position: "fixed", top: "4px" })); + await page.evaluate(() => { + document.addEventListener("animationstart", event => { + const node = event.target; + if (!(node instanceof HTMLElement) || node.getAttribute("role") !== "dialog") return; + const entry = node.getAnimations().find(animation => animation instanceof CSSAnimation); + if (!entry) return; + entry.pause(); + entry.currentTime = 0; + }); + }); + await trigger.click(); + const picker = page.getByRole("dialog"); + await expect(picker).toHaveAttribute("data-side", "bottom"); + await expect.poll(() => picker.evaluate(node => { + const transform = getComputedStyle(node).transform; + return transform === "none" ? 0 : new DOMMatrixReadOnly(transform).m42; + })).toBeLessThan(0); +}); + test("model picker management handoff keeps focus in the new dialog", async () => { await page.getByRole("button", { name: "First model", exact: true }).click(); await settleClose(() => page.getByRole("button", { name: "Manage presets" }).click()); diff --git a/webui/src/components/FileActions.tsx b/webui/src/components/FileActions.tsx index 7dea85e91..508c60be5 100644 --- a/webui/src/components/FileActions.tsx +++ b/webui/src/components/FileActions.tsx @@ -114,7 +114,7 @@ export function FileActions({ event.stopPropagation()} onContextMenu={(event) => { event.preventDefault(); event.stopPropagation(); }} onInteractOutside={() => { interactedOutside.current = true; }} @@ -122,6 +122,8 @@ export function FileActions({ event.preventDefault(); if (!interactedOutside.current) opener.current?.focus(); }}> + {/* Track the click point even when collision handling shifts the menu; render no visible arrow. */} + { event.preventDefault(); if (resolved) void copy(resolved.path); diff --git a/webui/src/components/thread/ModelPresetBadge.tsx b/webui/src/components/thread/ModelPresetBadge.tsx index b0e363086..dd4333236 100644 --- a/webui/src/components/thread/ModelPresetBadge.tsx +++ b/webui/src/components/thread/ModelPresetBadge.tsx @@ -434,7 +434,6 @@ export function ModelPresetBadge({ className={cn( showsSpeedControl ? speedPickerWidthClassName : pickerWidthClassName, "inset-scrollbar flex max-h-[var(--radix-popover-content-available-height)] flex-col overflow-y-auto", - "origin-[var(--radix-popover-content-transform-origin)] p-1.5 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-bottom-1 data-[state=open]:slide-in-from-bottom-1 duration-200 ease-out motion-reduce:animate-none", )} >