diff --git a/docs/webui.md b/docs/webui.md index dc7fb814d..ee7a2672e 100644 --- a/docs/webui.md +++ b/docs/webui.md @@ -192,7 +192,9 @@ On touch devices with Visual Viewport support, the app follows the visible area when the on-screen keyboard opens or pans the page. Navigation and the composer stay in view while messages scroll independently. Session search also follows the visible area: the search field stays above the keyboard and results scroll -inside the dialog. The `@` mention and `/` command +inside the dialog. In short landscape viewports, its input and results sit side +by side so a result remains reachable. Taller dialogs scroll from their top +instead of centering content outside the visible area. The `@` mention and `/` command menus use the visible app area above or below the composer, including when the keyboard pans the page. Scroll within a menu to reach more results. Mention rows use the app's larger touch targets on phones while retaining desktop density. diff --git a/webui/src/components/SessionSearchDialog.tsx b/webui/src/components/SessionSearchDialog.tsx index 0da4a277a..5a4ff6cfa 100644 --- a/webui/src/components/SessionSearchDialog.tsx +++ b/webui/src/components/SessionSearchDialog.tsx @@ -140,14 +140,14 @@ export function SessionSearchDialog({ {t("sidebar.searchAria")} {t("sidebar.searchPlaceholder")} -
+
-
+
{sectionLabel}
diff --git a/webui/src/components/ui/dialog.tsx b/webui/src/components/ui/dialog.tsx index 4d4232682..98fd1557c 100644 --- a/webui/src/components/ui/dialog.tsx +++ b/webui/src/components/ui/dialog.tsx @@ -24,7 +24,7 @@ const DialogOverlay = React.forwardRef< ref={ref} className={cn( modalOverlayClassName, - "motion-reduce:animate-none", + "duration-200 motion-reduce:animate-none", className, )} {...props} @@ -34,6 +34,8 @@ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; // The portal's presence ref must reach the animated content, not the plain // positioning wrapper; otherwise the wrapper unmounts before the exit finishes. +// Auto margins center/bottom-align surfaces when they fit, but collapse to zero +// when they overflow so the beginning of a tall dialog remains scrollable. const DialogPositionedContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { @@ -41,7 +43,7 @@ const DialogPositionedContent = React.forwardRef< placement?: "center" | "bottom"; } >(({ positionerStyle, placement, ...props }, ref) => ( -
- + ) : null} + ); }); diff --git a/webui/src/globals.css b/webui/src/globals.css index 5d689dc43..94ad53d3b 100644 --- a/webui/src/globals.css +++ b/webui/src/globals.css @@ -141,6 +141,25 @@ overflow-y: auto; } + /* Body portals share the viewport owner's short-frame state. A landscape + keyboard needs input and results beside each other, not stacked. */ + @media (min-width: 640px) { + body:has(> #root.short-visual-viewport) .session-search-dialog { + flex-direction: row; + } + + body:has(> #root.short-visual-viewport) .session-search-input { + width: 40%; + height: auto; + border-bottom-width: 0; + border-right-width: 1px; + } + + body:has(> #root.short-visual-viewport) .session-search-label { + @apply sr-only; + } + } + * { scrollbar-color: var(--scrollbar-thumb) transparent; scrollbar-width: thin; diff --git a/webui/src/tests/session-search-dialog.test.tsx b/webui/src/tests/session-search-dialog.test.tsx index deaf40963..dcc83b44c 100644 --- a/webui/src/tests/session-search-dialog.test.tsx +++ b/webui/src/tests/session-search-dialog.test.tsx @@ -1,7 +1,9 @@ -import { fireEvent, render, screen } from "@testing-library/react"; +import { useState } from "react"; +import { act, cleanup, fireEvent, render, screen } from "@testing-library/react"; import { afterEach, describe, expect, it, vi } from "vitest"; import { SessionSearchDialog } from "@/components/SessionSearchDialog"; +import { useAppViewport } from "@/hooks/useAppViewport"; import type { ChatSummary } from "@/lib/types"; function session(index: number): ChatSummary { @@ -29,9 +31,60 @@ describe("SessionSearchDialog", () => { expect(screen.getAllByRole("button").length).toBeLessThanOrEqual(24); }); afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); vi.restoreAllMocks(); }); + it("shares keyboard rotation and dismissal with the body portal without losing a draft", () => { + vi.stubGlobal("matchMedia", vi.fn(() => ({ + matches: true, addEventListener: vi.fn(), removeEventListener: vi.fn(), + }))); + const viewport = Object.assign(new EventTarget(), { height: 428, offsetTop: 0, scale: 1 }); + vi.stubGlobal("visualViewport", viewport); + const onSelect = vi.fn(); + function SearchApp() { + useAppViewport(); + const [open, setOpen] = useState(true); + return <> +