Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): hold the mobile zoom lock inside portalled overlays (#16150)

Nikita Kabardinca8e8ba90448
diff --git a/web/src/components/table/peek.tsx b/web/src/components/table/peek.tsx
index 1385d20720..7e504e5a78 100644
--- a/web/src/components/table/peek.tsx
+++ b/web/src/components/table/peek.tsx
@@ -7,7 +7,7 @@ import { type ListEntry } from "@/src/features/navigate-detail-pages/context";
import { cn } from "@/src/utils/tailwind";
import { memo, useCallback, useEffect, useState } from "react";
import { useRouter } from "next/router";
-import { useIsMobile } from "@/src/hooks/use-mobile";
+import { useIsHandheld } from "@/src/hooks/use-mobile";
import { getPathnameWithoutBasePath } from "@/src/utils/api";
import { urlSearchParamsToQuery } from "@/src/utils/navigation";
import { PeekTableStateProvider } from "@/src/components/table/peek/contexts/PeekTableStateContext";
@@ -154,7 +154,9 @@ function TablePeekViewComponent(props: TablePeekViewProps) {
const { isBetaEnabled: isV4 } = useV4Beta();
const itemId = router.query.peek as string | undefined;
const isExpanded = router.query[PEEK_VIEW_PARAM] === PEEK_VIEW_EXPANDED;
- const isMobile = useIsMobile();
+ // Handheld, not width-only: a phone in landscape is wider than `md` but is
+ // still a phone, and must get the full-screen drawer rather than the sheet.
+ const isHandheld = useIsHandheld();
// Expanded is view state, owned by the peek and reflected in the URL so it is
// shareable + survives reload. Managed here (not threaded through every table
@@ -209,7 +211,7 @@ function TablePeekViewComponent(props: TablePeekViewProps) {
const ignoredSelectors = props.peekEventOptions?.ignoredSelectors ?? [];
// Gate the first render on mount so we never paint the desktop sheet before
- // `useIsMobile` resolves (which would flash the wrong shell on a mobile
+ // `useIsHandheld` resolves (which would flash the wrong shell on a mobile
// deep-link). Click-to-open is already post-mount, so it has no delay.
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
@@ -245,7 +247,7 @@ function TablePeekViewComponent(props: TablePeekViewProps) {
actions={props.actions}
actionsMenu={props.actionsMenu}
expand={
- isMobile
+ isHandheld
? undefined
: {
isExpanded: panel.isExpanded,
@@ -279,7 +281,7 @@ function TablePeekViewComponent(props: TablePeekViewProps) {
// `return null` above), which is what resets the state (see README).
return (
<PeekTableStateProvider>
- {isMobile ? (
+ {isHandheld ? (
// Mobile: a vaul bottom drawer with native swipe-down dismissal.
<Drawer
open={!!itemId}
diff --git a/web/src/components/table/peek/README.md b/web/src/components/table/peek/README.md
index de4d24b35a..dc58591692 100644
--- a/web/src/components/table/peek/README.md
+++ b/web/src/components/table/peek/README.md
@@ -15,8 +15,10 @@ Peek views allow users to quickly preview table items in a side panel. When navi
table behind stays interactive. A left-edge handle resizes it; dragging to the
far edge (or the header Expand button) **expands** it to the max width
(viewport − sidebar; the sidebar stays visible).
-- **Mobile** (`useIsMobile`, <768px) — a `vaul` bottom drawer with native
- swipe-down dismissal (Expand is hidden).
+- **Handheld** (`useIsHandheld` — narrower than `md`, _or_ a coarse pointer on a
+ short screen, i.e. a phone in landscape) — a `vaul` bottom drawer with native
+ swipe-down dismissal (Expand is hidden). Not width-only: a landscape phone is
+ wider than `md` and would otherwise get the desktop sheet.
Dismissal:
diff --git a/web/src/features/trace-graph-view/components/ElkGraphRenderer.tsx b/web/src/features/trace-graph-view/components/ElkGraphRenderer.tsx
index a7a4196ea4..e8ba0caf7d 100644
--- a/web/src/features/trace-graph-view/components/ElkGraphRenderer.tsx
+++ b/web/src/features/trace-graph-view/components/ElkGraphRenderer.tsx
@@ -359,7 +359,9 @@ export const ElkGraphRenderer: React.FC<ElkGraphRendererProps> = ({
ref={containerRef}
role="group"
aria-label="Trace agent graph"
- className="bg-background/50 relative h-full w-full cursor-grab overflow-hidden active:cursor-grabbing"
+ // `touch-none`: d3-zoom owns pan and pinch here. Without it WebKit zooms
+ // the page instead, since `preventDefault` cannot cancel its pinch.
+ className="bg-background/50 relative h-full w-full cursor-grab touch-none overflow-hidden active:cursor-grabbing"
onPointerDown={(e) =>
(pointerDownPos.current = { x: e.clientX, y: e.clientY })
}
diff --git a/web/src/pages/_app.tsx b/web/src/pages/_app.tsx
index 02b60125a7..836e5f98d2 100644
--- a/web/src/pages/_app.tsx
+++ b/web/src/pages/_app.tsx
@@ -151,8 +151,9 @@ const MyApp: AppType<{ session: Session | null }> = ({
{/* Replaces Next's default `width=device-width` (next/head dedupes by
name). `maximum-scale=1` stops iOS Safari auto-zooming a focused
sub-16px field; iOS ignores `user-scalable=no` for user gestures, so
- the engine-level zoom block is `touch-action` on html/body
- (styles/globals.css). `viewport-fit=cover` is what makes
+ the engine-level zoom block is `touch-action` on `#__next` and the
+ overlay layers — NOT on html/body, which WebKit ignores for page
+ pinch (styles/globals.css). `viewport-fit=cover` is what makes
`env(safe-area-inset-*)` non-zero. */}
<Head>
<meta
diff --git a/web/src/styles/globals.css b/web/src/styles/globals.css
index 9b2437efc7..53b7a5eba2 100644
--- a/web/src/styles/globals.css
+++ b/web/src/styles/globals.css
@@ -607,10 +607,21 @@
body {
/* Prevent pull-to-refresh and rubber-banding on the page level only */
overscroll-behavior-y: none;
- /* Omitting `pinch-zoom` blocks pinch and double-tap zoom at the engine
- level, which modern iOS honors where it ignores `user-scalable=no`
- (viewport meta lives in pages/_app.tsx). Elements that own their own
- gestures set their own `touch-action`. */
+ }
+
+ /* The page never zooms, so a pinch belongs to the surface under it (omitting
+ `pinch-zoom` is the block; the viewport meta lives in pages/_app.tsx).
+ Naming `html, body` alone is NOT enough: WebKit ignores root-level
+ `touch-action` for page pinch, just as it ignores `user-scalable=no`, and
+ overlays portal OUT of `#__next` into the layer containers, so each needs
+ the declaration. Deliberately layered — vaul injects
+ `[data-vaul-drawer]{touch-action:none}` unlayered, which beats any layer;
+ that is stricter, so the drawer keeps owning its drag. Surfaces that own a
+ gesture set their own `touch-action` (a `touch-*` utility wins over this). */
+ html,
+ body,
+ div#__next,
+ [data-overlay-root] > [data-layer] > * {
touch-action: pan-x pan-y;
}