The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Top bar menus: steadier switching, focus kept in fields, cleaner morph
Adarshccdf6e866fed
diff --git a/src/app/motion.css b/src/app/motion.cssindex 1a6861bb..d2091522 100644--- a/src/app/motion.css+++ b/src/app/motion.css@@ -160,11 +160,14 @@[data-mega-panel] {--launcher-step: calc(var(--motion-stagger) * 0.5);--enter-delay: 0ms;+ --exit-fade: var(--motion-fast);opacity: 0;translate: var(--exit-x, 0px) var(--exit-y, calc(var(--motion-d1) * -1));pointer-events: none;+ /* Cut at the shared sheet's edge (--panel-h, set on the bar): a taller panel never shows past it mid-switch. */+ clip-path: inset(0 0 max(0px, calc(100% - var(--panel-h, 100%))) 0);transition:- opacity var(--motion-fast) var(--ease-exit),+ opacity var(--exit-fade) var(--ease-exit),translate var(--motion-fast) var(--ease-exit);&[hidden] { display: none; }&[data-phase="open"] {@@ -178,10 +181,10 @@/* The one in front during a switch is the new one; the old one fades under it. */&[data-phase="exit"] { z-index: 0; }&[data-phase="open"] { z-index: 1; }- &[data-phase="open"][data-enter="fresh"] [data-col] { animation: motion-rise-near var(--motion-base) var(--ease-enter) backwards; }- &[data-phase="open"][data-enter="fresh"] [data-col="1"] { animation-delay: var(--launcher-step); }- &[data-phase="open"][data-enter="fresh"] [data-col="2"] { animation-delay: calc(var(--launcher-step) * 2); }- &[data-phase="open"][data-enter="fresh"] :is([data-col="3"], [data-col="4"], [data-col="5"], [data-col="6"], [data-col="7"], [data-col="8"]) { animation-delay: calc(var(--launcher-step) * 3); }+ &[data-phase="open"][data-mega-enter="fresh"] [data-col] { animation: motion-rise-near var(--motion-base) var(--ease-enter) backwards; }+ &[data-phase="open"][data-mega-enter="fresh"] [data-col="1"] { animation-delay: var(--launcher-step); }+ &[data-phase="open"][data-mega-enter="fresh"] [data-col="2"] { animation-delay: calc(var(--launcher-step) * 2); }+ &[data-phase="open"][data-mega-enter="fresh"] :is([data-col="3"], [data-col="4"], [data-col="5"], [data-col="6"], [data-col="7"], [data-col="8"]) { animation-delay: calc(var(--launcher-step) * 3); }/* A menu still loading: its skeleton shows only after a moment (most loads finish first). */& [data-mega-skeleton] { animation: motion-fade var(--motion-fast) var(--ease-enter) 150ms backwards; }}@@ -191,9 +194,23 @@translate: var(--enter-x, 0px) var(--enter-y, calc(var(--motion-d2) * -1));}}+/* A switch between two big panels: each one's cut follows the sheet's edge, on the sheet's own timing. */+[data-top-bar]:has([data-mega-stage][data-morph]) [data-mega-panel] {+ transition:+ opacity var(--exit-fade) var(--ease-exit),+ translate var(--motion-fast) var(--ease-exit),+ clip-path var(--motion-base) var(--ease-standard);+ &[data-phase="open"] {+ transition:+ opacity var(--motion-base) var(--ease-enter) var(--enter-delay),+ translate var(--motion-base) var(--ease-enter) var(--enter-delay),+ clip-path var(--motion-base) var(--ease-standard);+ }+}[data-mega-stage] {& [data-mega-backdrop] { translate: 0 calc(var(--panel-h, 0px) - 100%); }&[data-morph] [data-mega-backdrop] { transition: translate var(--motion-base) var(--ease-standard); }+ /* Comes down 8 px with the content (from where it rests while gone), goes back up 4 px. */& [data-mega-sheet] {opacity: 0;translate: 0 calc(var(--motion-d1) * -1);@@ -201,6 +218,7 @@opacity var(--motion-fast) var(--ease-exit),translate var(--motion-fast) var(--ease-exit);}+ &[data-phase="gone"] [data-mega-sheet] { translate: 0 calc(var(--motion-d2) * -1); transition: none; }&[data-open] [data-mega-sheet] {opacity: 1;translate: 0 0;@@ -258,7 +276,11 @@transition: opacity var(--motion-fast) var(--ease-exit) 120ms;&[data-open] { opacity: 0.5; transition: opacity var(--motion-base) var(--ease-standard); }}-/* The bar and an open big panel read as one surface: the bar's bottom line steps aside. */+/* The overlay reads lighter on a dark page: a little more of it there, for the same calm dim. */+.dark [data-bar-scrim][data-open] { opacity: 0.7; }+/* The bar and an open big panel read as one surface: the bar's bottom line fades aside with the sheet coming in, and+ back as it goes. */+[data-top-bar] { transition: border-color var(--motion-fast) var(--ease-standard); }[data-top-bar]:has([data-mega-stage][data-open]) { border-bottom-color: transparent; }/* The chevron turns while its menu is open (a transition, so a reversal mid-turn starts from where it is). */[data-bar-chevron] { transition: transform var(--motion-base) var(--ease-standard); }diff --git a/src/components/nav/bar-menus.tsx b/src/components/nav/bar-menus.tsxindex 92e2e622..386215b3 100644--- a/src/components/nav/bar-menus.tsx+++ b/src/components/nav/bar-menus.tsx@@ -1,6 +1,6 @@"use client";-import { usePathname } from "next/navigation";+import { usePathname, useSearchParams } from "next/navigation";import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";import {aiming,@@ -9,6 +9,7 @@ import {restStart,switchDirection,switchesAtOnce,+ travelling,type BarMenuAction,type BarMenuId,type BarMenuState,@@ -29,7 +30,8 @@ import { useNavUi } from "./nav-ui";* mouse resting on an item opens its menu (NAV_INTENT.rest; a glide along the bar opens nothing); while one is* open, moving onto another item switches at once, unless the pointer is heading into the open menu (the* safe triangle, a short hold). A menu the pointer opened closes a moment after the pointer leaves it.- * click opens a menu pinned (a click on a menu the pointer opened pins it; a click on a pinned one closes it).+ * click toggles: a click opens the menu (it still closes once the mouse leaves it, as a hover-opened one does); a+ * click on a menu the pointer opened keeps it; the next click closes it. A double click counts once.* Ctrl/Cmd-click or a middle click opens the item's page in a new tab.* touch/pen never hover: a tap toggles, a tap on another item switches, a tap outside only closes.* keys Enter/Space toggle (focus stays on the item); ArrowDown/ArrowUp open and focus the first/last row;@@ -136,7 +138,28 @@ export function createBarController(act: (a: BarMenuAction) => BarMenuState, sta);timer = t;};- const isAiming = (id: BarMenuId) => aiming(exit, box(parts.get(id)?.surface), moves.slice(-4), now());+ /** The pointer's way just now: its last few moves of the last 100 ms (or its last two, after a pause). */+ const recentMoves = (t: number) => {+ const recent = moves.filter((m) => t - m.t <= 100);+ return recent.length >= 2 ? recent.slice(-4) : moves.slice(-2);+ };+ const isAiming = (id: BarMenuId) => {+ const t = now();+ return aiming(exit, box(parts.get(id)?.surface), recentMoves(t), t);+ };+ const track = (x: number, y: number) => {+ moves.push({ x, y, t: now() });+ if (moves.length > 10) moves.shift();+ };+ /**+ * A menu is going (closing, or replaced by `to`) with focus on one of its rows: focus moves to its item (or to the+ * new menu's item) instead of falling to the page. Focus is only ever in a menu that the keys or the item already had.+ */+ const handBack = (from: BarMenuId, to?: BarMenuId) => {+ const a = document.activeElement;+ if (!a || !parts.get(from)?.surface?.contains(a)) return;+ parts.get(to ?? from)?.trigger?.focus({ preventScroll: true });+ };const open = (id: BarMenuId, mode: "hover" | "pinned", via: MenuVia) => {clear();@@ -146,6 +169,7 @@ export function createBarController(act: (a: BarMenuAction) => BarMenuState, sta/** Onto another item while a menu is open (or just closed): it takes over at once, in the open one's mode. */const switchTo = (id: BarMenuId) => {const s = state();+ if (s.id) handBack(s.id, id);open(id, s.id ? s.mode : "hover", "pointer");};const close = (id: BarMenuId, focusBack = false) => {@@ -153,6 +177,7 @@ export function createBarController(act: (a: BarMenuAction) => BarMenuState, staif (s.id !== id) return;clear();const back = focusBack ? (s.via === "area" && returnTo()?.isConnected ? returnTo() : parts.get(id)?.trigger) : null;+ if (!back) handBack(id);act({ type: "close", id, now: now() });back?.focus();};@@ -168,7 +193,20 @@ export function createBarController(act: (a: BarMenuAction) => BarMenuState, stago();};const armRest = (id: BarMenuId) => {- if (rest) arm("open", id, restDue(rest) - now(), () => hoverOpen(id));+ if (!rest) return;+ const r = rest;+ const due = restDue(r);+ // Due by the cap (the pointer never stopped): it opens only if the pointer is not still drifting along the bar.+ const capped = due < r.anchor.t + NAV_INTENT.rest;+ arm("open", id, due - now(), () => {+ const t = now();+ if (capped && travelling(moves, t)) {+ const last = moves[moves.length - 1];+ rest = restStart(last.x, last.y, t);+ return armRest(id);+ }+ hoverOpen(id);+ });};const armClose = (id: BarMenuId, held = 0) => {arm("close", id, held ? 50 : NAV_INTENT.grace, () => {@@ -176,9 +214,22 @@ export function createBarController(act: (a: BarMenuAction) => BarMenuState, staif (s.id !== id || s.mode !== "hover" || hoverOn === id || overSurface === id) return;// Still heading into the menu (a long diagonal): hold the close a little longer.if (held < NAV_INTENT.aimMax && isAiming(id)) return armClose(id, held + 50);+ handBack(id);act({ type: "close", id, now: now() });});};+ /**+ * Crossing `id` on the way into the open menu: its switch waits (aimHold), and a little longer while the pointer+ * keeps heading in (a wide item crossed slowly), up to aimMax; a stop or a turn along the bar switches at once.+ */+ const holdSwitch = (id: BarMenuId, held = 0) => {+ arm("switch", id, held ? 50 : NAV_INTENT.aimHold, () => {+ if (hoverOn !== id) return;+ const s = state();+ if (s.id && s.id !== id && held < NAV_INTENT.aimMax && isAiming(s.id)) return holdSwitch(id, held + 50);+ switchTo(id);+ });+ };const warm = (id: BarMenuId) => parts.get(id)?.warm?.();const hubOf = (id: BarMenuId) => parts.get(id)?.trigger?.dataset.href;const newTab = (href: string) => window.open(href, "_blank", "noopener");@@ -215,8 +266,11 @@ export function createBarController(act: (a: BarMenuAction) => BarMenuState, stareturn;}if (switchesAtOnce(s, now())) {- // Crossing this item on the way into an open card (Create, More): hold the switch a moment.- if (s.id && !parts.get(s.id)?.big && isAiming(s.id)) return arm("switch", id, NAV_INTENT.aimHold, () => hoverOn === id && switchTo(id));+ // The browser sends enter before the move that caused it: count this point first, so the check below sees+ // where the pointer is now, not where it was inside the item it left.+ track(e.clientX, e.clientY);+ // Crossing this item on the way into the open menu (a diagonal from its item): hold the switch a moment.+ if (s.id && isAiming(s.id)) return holdSwitch(id);return switchTo(id);}rest = restStart(e.clientX, e.clientY, now());@@ -248,13 +302,15 @@ export function createBarController(act: (a: BarMenuAction) => BarMenuState, staif (s.mode === "hover") armClose(id);},onClick(e) {+ const pt = (e.nativeEvent as PointerEvent).pointerType;+ // A mouse double click counts once (its second click would close what the first opened); two quick taps are two.+ if (e.detail > 1 && (pt || lastType) === "mouse") return;const href = hubOf(id);if ((e.ctrlKey || e.metaKey) && href) {e.preventDefault();newTab(href);return;}- const pt = (e.nativeEvent as PointerEvent).pointerType;const via: MenuVia = e.detail === 0 && !pt ? "key" : (pt || lastType) === "mouse" ? "pointer" : "touch";clear();rest = null;@@ -299,10 +355,14 @@ export function createBarController(act: (a: BarMenuAction) => BarMenuState, sta},onPointerMove(e) {// The mouse moves the keyboard's place: the row under it takes focus (quietly: the ring is the keyboard's), so the- // arrow keys go on from where the mouse left off and only one row is ever highlighted.+ // arrow keys go on from where the mouse left off and only one row is ever highlighted. Only while focus is+ // already this menu's (its item, a row) or nowhere: a field being typed in keeps focus, and its keys.if (e.pointerType !== "mouse") return;+ const a = document.activeElement;+ const p = parts.get(id);+ if (a && a !== document.body && !p?.trigger?.contains(a) && !p?.surface?.contains(a)) return;const at = (e.target as HTMLElement).closest<HTMLElement>("[data-col]");- if (at && at !== document.activeElement) at.focus({ preventScroll: true });+ if (at && at !== a) at.focus({ preventScroll: true });},onPointerLeave(e) {if (e.pointerType !== "mouse") return;@@ -350,16 +410,36 @@ export function createBarController(act: (a: BarMenuAction) => BarMenuState, staconst onMove = (e: PointerEvent) => {lastType = e.pointerType;if (e.pointerType !== "mouse") return;- moves.push({ x: e.clientX, y: e.clientY, t: now() });- if (moves.length > 6) moves.shift();+ track(e.clientX, e.clientY);};- const swallowClick = () => {+ /** Drops the click of this one tap (where it pressed, soon after); a tap that became a scroll leaves no blocker. */+ const swallowClick = (down: PointerEvent) => {const stop = (ev: MouseEvent) => {+ done();+ if (Math.hypot(ev.clientX - down.clientX, ev.clientY - down.clientY) >= 10) return;ev.preventDefault();ev.stopPropagation();};- document.addEventListener("click", stop, { capture: true, once: true });- window.setTimeout(() => document.removeEventListener("click", stop, true), 800);+ const cancel = (ev: PointerEvent) => {+ if (ev.pointerId === down.pointerId) done();+ };+ const t = window.setTimeout(() => done(), 500);+ const done = () => {+ window.clearTimeout(t);+ document.removeEventListener("click", stop, true);+ document.removeEventListener("pointercancel", cancel, true);+ };+ document.addEventListener("click", stop, true);+ document.addEventListener("pointercancel", cancel, true);+ };+ /** A resize hid the open menu's item (the bar drops items as it narrows): its menu closes with it. */+ const onResize = () => {+ const s = state();+ const t = s.id ? parts.get(s.id)?.trigger : null;+ if (s.id && (!t || !shows(t))) {+ clear();+ act({ type: "close", id: s.id, now: now() });+ }};const onDown = (e: PointerEvent) => {lastType = e.pointerType;@@ -370,7 +450,7 @@ export function createBarController(act: (a: BarMenuAction) => BarMenuState, staif (target?.closest?.("[data-bar-menu]") || parts.get(s.id)?.surface?.contains(target)) return;close(s.id);// A tap meant to dismiss never follows a link on the dimmed page under it.- if (e.pointerType === "touch" || e.pointerType === "pen") swallowClick();+ if (e.pointerType === "touch" || e.pointerType === "pen") swallowClick(e);};const onKey = (e: KeyboardEvent) => {if (e.key !== "Escape" || e.defaultPrevented) return;@@ -399,12 +479,14 @@ export function createBarController(act: (a: BarMenuAction) => BarMenuState, stadocument.addEventListener("pointerdown", onDown, true);document.addEventListener("keydown", onKey);document.addEventListener("focusout", onFocusOut);+ window.addEventListener("resize", onResize);return () => {clear();document.removeEventListener("pointermove", onMove, true);document.removeEventListener("pointerdown", onDown, true);document.removeEventListener("keydown", onKey);document.removeEventListener("focusout", onFocusOut);+ window.removeEventListener("resize", onResize);};};@@ -483,16 +565,27 @@ export function BarMenusProvider({ children }: { children: React.ReactNode }) {return <BarCtx.Provider value={ctl}>{children}</BarCtx.Provider>;}-/** A new page (a link, back, a notification) closes the open menu. Reads the path: render it inside Suspense. */+/**+ * A new page (a link, back or forward, a notification; a change of query counts) closes the open menu, unless the+ * pointer opened it and is on it now (it rested on an item while the page was loading). Reads the URL: render it+ * inside Suspense.+ */export function CloseMenusOnRoute() {const pathname = usePathname();+ const query = useSearchParams().toString();+ const url = `${pathname}?${query}`;+ const ctl = useBarController();const { menuNow, menuAct } = useNavUi();- const at = useRef(pathname);+ const at = useRef(url);useEffect(() => {- if (at.current === pathname) return;- at.current = pathname;- if (menuNow().id) menuAct({ type: "close", now: performance.now() });- }, [pathname, menuNow, menuAct]);+ if (at.current === url) return;+ at.current = url;+ const s = menuNow();+ if (!s.id) return;+ const p = ctl?.part(s.id);+ const held = s.mode === "hover" && (!!p?.trigger?.matches(":hover") || !!p?.surface?.matches(":hover"));+ if (!held) menuAct({ type: "close", now: performance.now() });+ }, [url, ctl, menuNow, menuAct]);return null;}@@ -528,7 +621,13 @@ export function useBarMenu(id: BarMenuId, { big = false, ready, warm }: { big?:const other = open ? menu.prev : menu.id;const sideways = big && !!other && !!ctl?.part(other)?.big;const dir = open ? switchDirection(menu.prev, id) : switchDirection(id, menu.id);- const motion = sideways && dir ? (open ? { "--enter-x": `calc(var(--motion-d2) * ${dir})`, "--enter-y": "0px", "--enter-delay": "var(--motion-stagger)" } : { "--exit-x": `calc(var(--motion-d2) * ${-dir})`, "--exit-y": "0px" }) : {};+ // The old content is gone (two thirds of fast) before the new one starts (two staggers): never two panels' words at once.+ const motion =+ sideways && dir+ ? open+ ? { "--enter-x": `calc(var(--motion-d2) * ${dir})`, "--enter-y": "0px", "--enter-delay": "calc(var(--motion-stagger) * 2)" }+ : { "--exit-x": `calc(var(--motion-d2) * ${-dir})`, "--exit-y": "0px", "--exit-fade": "calc(var(--motion-fast) * .67)" }+ : {};return {open,phase,@@ -556,22 +655,24 @@ export function BarIndicator() {el.removeAttribute("data-on");return;}+ /** Puts the highlight on the item; false when the item is hidden (a narrower window). */const place = () => {const host = el.parentElement?.getBoundingClientRect();const r = trig.getBoundingClientRect();- if (!host || !r.width) return;+ if (!host || !r.width) return false;el.style.width = `${r.width}px`;el.style.height = `${r.height}px`;el.style.translate = `${r.left - host.left}px ${r.top - host.top}px`;+ return true;};// Slides only from one open item to the next; from nothing it shows in place. The slide moves transform only: the// box takes the new item's size at once and starts scaled to the old one's width, then settles (FLIP).const slide = el.hasAttribute("data-on") && !!menu.prev;const was = slide ? { w: parseFloat(el.style.width), t: el.style.translate } : null;el.removeAttribute("data-slide");- place();+ const shown = place();const w = parseFloat(el.style.width);- if (was && w > 0 && was.w > 0) {+ if (shown && was && w > 0 && was.w > 0) {const to = el.style.translate;el.style.translate = was.t;el.style.scale = `${was.w / w} 1`;@@ -580,13 +681,15 @@ export function BarIndicator() {el.style.translate = to;el.style.scale = "1 1";} else el.style.scale = "1 1";- el.setAttribute("data-on", "");- const ro = new ResizeObserver(place);+ el.toggleAttribute("data-on", shown);+ // No highlight left between the items that show when its item hides.+ const follow = () => el.toggleAttribute("data-on", place());+ const ro = new ResizeObserver(follow);ro.observe(trig);- window.addEventListener("resize", place);+ window.addEventListener("resize", follow);return () => {ro.disconnect();- window.removeEventListener("resize", place);+ window.removeEventListener("resize", follow);};}, [ctl, menu.id, menu.prev]);return <span ref={ref} aria-hidden data-bar-indicator className="pointer-events-none absolute top-0 left-0 rounded-[10px] print:hidden" />;@@ -602,11 +705,13 @@ export function BarStage() {const ref = useRef<HTMLDivElement>(null);const big = menu.id && ctl?.part(menu.id)?.big ? menu.id : null;const morph = !!big && !!menu.prev && !!ctl?.part(menu.prev)?.big;+ const phase = usePresence(!!big);useLayoutEffect(() => {- const stage = ref.current;+ // On the bar, so the panels read it too: during a switch each one is cut at the sheet's moving edge (motion.css).+ const host = ref.current?.closest<HTMLElement>("[data-top-bar]") ?? ref.current;const panel = big ? ctl?.part(big)?.surface : null;- if (!stage || !panel) return;- const set = () => stage.style.setProperty("--panel-h", `${panel.offsetHeight}px`);+ if (!host || !panel) return;+ const set = () => host.style.setProperty("--panel-h", `${panel.offsetHeight}px`);set();const ro = new ResizeObserver(set);ro.observe(panel);@@ -617,6 +722,7 @@ export function BarStage() {ref={ref}aria-hiddendata-mega-stage+ data-phase={phase}data-open={big ? "" : undefined}data-morph={morph ? "" : undefined}className="pointer-events-none absolute inset-x-0 top-full h-[calc(100dvh-3.5rem)] overflow-hidden print:hidden"diff --git a/src/components/nav/create-menu.tsx b/src/components/nav/create-menu.tsxindex 78384127..10d6bb16 100644--- a/src/components/nav/create-menu.tsx+++ b/src/components/nav/create-menu.tsx@@ -54,7 +54,9 @@ export function CreateList({ variant, onNavigate }: { variant: "menu" | "sheet";return (<>{/* The area's own page: first in Tab order (the item, then See all, then the rows), at the top right. */}- <SeeAllRow href={CREATE_AREA_HREF} name="See all of Create" data-see-all className="absolute top-1.5 right-1.5 h-8" />+ <div className="absolute top-1.5 right-1.5 z-10">+ <SeeAllRow href={CREATE_AREA_HREF} name="See all of Create" data-see-all className="h-8" />+ </div><div className="grid grid-cols-2 gap-x-1.5">{columns.map((c, i) => (<div key={c.label} role="group" aria-labelledby={`${ids}-${i}`} className="flex min-w-0 flex-col">diff --git a/src/components/nav/mega-launcher.tsx b/src/components/nav/mega-launcher.tsxindex 99f11479..c2d960d0 100644--- a/src/components/nav/mega-launcher.tsx+++ b/src/components/nav/mega-launcher.tsx@@ -4,7 +4,7 @@ import { lazy, Suspense, useCallback, useEffect, useState } from "react";import { MEGA_AREAS, megaMove, megaPanelId, TILE_COLS, type MegaId } from "@/lib/mega-menus";import { launcherActive, studioCount, subActive } from "@/lib/nav-model";import { cn } from "@/lib/utils";-import { BarScrim, useBarMenu } from "./bar-menus";+import { useBarMenu } from "./bar-menus";import { BarTrigger } from "./bar-split";import { menuReady, warmMenu } from "./mega-data";import { useSearchPalette } from "./search-context";@@ -139,12 +139,14 @@ export function MegaLauncher({ id, active, className }: { id: MegaId; active?: bid={id}panelId={megaPanelId(id)}href={area.href}- name={n !== undefined ? `${area.label}, ${n} studios` : undefined}label={n !== undefined ? (+ /* Spoken "Studios, 29 studios": the visible words start the name (no separate label to drift from them). */<span className="inline-flex items-center gap-1.5">{area.label}+ <span className="sr-only">,</span><span className="rounded-full bg-brand-faint px-1.5 py-px text-[11px] leading-4 font-semibold text-brand-text tabular-nums">{n}</span>+ <span className="sr-only"> studios</span></span>) : (area.label@@ -157,14 +159,15 @@ export function MegaLauncher({ id, active, className }: { id: MegaId; active?: bdata-mega={id}data-mega-trigger={id}data-studios-trigger={id === "studios" || undefined}- className={className}+ /* Open, its hit area reaches down to the panel: resting in the gap between them keeps the menu. */+ className={cn("data-[open]:after:absolute data-[open]:after:inset-x-0 data-[open]:after:top-full data-[open]:after:h-2 data-[open]:after:content-['']", className)}/><sectionref={surfaceRef}id={megaPanelId(id)}data-mega-panel={id}data-phase={phase}- data-enter={entered}+ data-mega-enter={entered}aria-label={area.panel}hidden={phase === "gone"}inert={phase !== "open"}@@ -198,12 +201,3 @@ export function MegaLauncher({ id, active, className }: { id: MegaId; active?: b</>);}--/** The bar's Studios item (MegaLauncher for Studios). */-export function StudiosLauncher(props: { active?: boolean }) {- return <MegaLauncher id="studios" {...props} />;-}--/** Kept names: the dimmed page under the bar's menus (one for all six: BarScrim). */-export const MegaScrim = BarScrim;-export const LauncherScrim = BarScrim;diff --git a/src/components/nav/nav-ui.tsx b/src/components/nav/nav-ui.tsxindex fd546f85..8f14cd4e 100644--- a/src/components/nav/nav-ui.tsx+++ b/src/components/nav/nav-ui.tsx@@ -28,10 +28,6 @@ export interface NavUi {menuAct(a: BarMenuAction): BarMenuState;/** The menu state now (for timers and handlers: never a render behind). */menuNow(): BarMenuState;- /** Opens a menu pinned (by its own button), or closes the open one (null). */- setOpenMenu(v: BarMenuId | null): void;- /** The column the open menu was opened for (openArea(id, group)): it takes focus first. */- menuGroup: string | undefined;/** Where focus goes back to when the menu closes with Esc: what opened it, when that was not its own button. */menuReturnTo(): HTMLElement | null;sheet: NavSheet | null;@@ -66,15 +62,6 @@ export function NavUiProvider({ covers, children }: { covers: NavCovers; childrereturn next;}, []);const menuNow = useCallback(() => menuRef.current, []);- // Opened or closed by a menu's own button: focus goes back to it. openArea() says otherwise.- const setOpenMenu = useCallback(- (id: BarMenuId | null) => {- menuReturn.current = null;- const now = performance.now();- menuAct(id ? { type: "open", id, mode: "pinned", via: "pointer", clicked: true, now } : { type: "close", now });- },- [menuAct],- );const menuReturnTo = useCallback(() => menuReturn.current, []);const setSheet = useCallback((v: NavSheet | null) => setSheetState((s) => ({ sheet: v, family: v === "studios" && s.sheet === "studios" ? s.family : "studios" })), []);const openArea = useCallback((id: MegaId, group?: string) => {@@ -95,8 +82,6 @@ export function NavUiProvider({ covers, children }: { covers: NavCovers; childremenu,menuAct,menuNow,- setOpenMenu,- menuGroup: menu.id ? menu.group : undefined,menuReturnTo,sheet: sheet.sheet,setSheet,@@ -105,7 +90,7 @@ export function NavUiProvider({ covers, children }: { covers: NavCovers; childreopenArea,openStudios,}),- [menu, sheet, menuAct, menuNow, setOpenMenu, menuReturnTo, setSheet, openArea, openStudios],+ [menu, sheet, menuAct, menuNow, menuReturnTo, setSheet, openArea, openStudios],);return (@@ -120,8 +105,6 @@ const CLOSED: NavUi = {menu: CLOSED_MENUS,menuAct: () => CLOSED_MENUS,menuNow: () => CLOSED_MENUS,- setOpenMenu: () => {},- menuGroup: undefined,menuReturnTo: () => null,sheet: null,setSheet: () => {},diff --git a/src/components/nav/top-bar.tsx b/src/components/nav/top-bar.tsxindex 97b55e48..61f6bdd9 100644--- a/src/components/nav/top-bar.tsx+++ b/src/components/nav/top-bar.tsx@@ -263,15 +263,28 @@ export function warmBar(): void {loadMenusNow(ids);}-/** Soon after the page is ready (idle, or 1.5 s at the latest), so the first hover never meets a skeleton. */+/**+ * Soon after the page has loaded (its first media come first; then idle, or 1.5 s at the latest), so the first hover+ * never meets a skeleton. The pointer or focus coming near the bar warms the menus at once (MainNav).+ */function MenuPrefetch() {useEffect(() => {- if (typeof window.requestIdleCallback !== "function") {- const t = window.setTimeout(warmBar, 300);- return () => window.clearTimeout(t);+ let stop = () => {};+ const schedule = () => {+ if (typeof window.requestIdleCallback !== "function") {+ const t = window.setTimeout(warmBar, 300);+ stop = () => window.clearTimeout(t);+ return;+ }+ const h = window.requestIdleCallback(warmBar, { timeout: 1500 });+ stop = () => window.cancelIdleCallback(h);+ };+ if (document.readyState === "complete") schedule();+ else {+ window.addEventListener("load", schedule, { once: true });+ stop = () => window.removeEventListener("load", schedule);}- const h = window.requestIdleCallback(warmBar, { timeout: 1500 });- return () => window.cancelIdleCallback(h);+ return () => stop();}, []);return null;}diff --git a/src/lib/bar-intent.ts b/src/lib/bar-intent.tsindex 0a23a66f..fc08c95c 100644--- a/src/lib/bar-intent.ts+++ b/src/lib/bar-intent.ts@@ -45,7 +45,10 @@ export type BarMenuAction =* own click or key (the next click closes it).*/| { type: "open"; id: BarMenuId; mode: MenuMode; via: MenuVia; group?: string; clicked?: boolean; now: number }- /** A click or tap on an item: open it pinned; pin it when the pointer opened it; close it when pinned. */+ /**+ * A click or tap on an item: open it (a tap pins it; a mouse click opens it as a hover does); a click on a menu the+ * pointer opened marks it clicked (a tap also pins it); a click on a clicked one closes it.+ */| { type: "click"; id: BarMenuId; via: MenuVia; now: number }/** Close the open menu, or (with `id`) only if `id` is the open one. */| { type: "close"; id?: BarMenuId; now: number };@@ -63,11 +66,13 @@ export function barMenus(s: BarMenuState, a: BarMenuAction): BarMenuState {return { id: a.id, mode: a.mode, via: a.via, clicked: !!a.clicked, group: a.group, prev: s.id, closedAt: s.closedAt, seq: s.seq + 1 };}case "click": {+ // The mouse never pins: a menu it opens or clicks still closes once the pointer leaves it (keys and taps pin).+ const mouse = a.via === "pointer";if (s.id === a.id) {- if (!s.clicked) return { ...s, mode: "pinned", via: a.via, clicked: true };+ if (!s.clicked) return mouse ? { ...s, clicked: true } : { ...s, mode: "pinned", via: a.via, clicked: true };return barMenus(s, { type: "close", id: a.id, now: a.now });}- return barMenus(s, { type: "open", id: a.id, mode: "pinned", via: a.via, clicked: true, now: a.now });+ return barMenus(s, { type: "open", id: a.id, mode: mouse ? "hover" : "pinned", via: a.via, clicked: true, now: a.now });}case "close": {if (s.id === null || (a.id !== undefined && a.id !== s.id)) return s;@@ -111,6 +116,16 @@ export function restDue(r: Rest, rest: number = NAV_INTENT.rest, cap: number = Nreturn Math.min(r.anchor.t + rest, r.enterAt + cap);}+/**+ * The pointer is still travelling across the bar: over the last `window` ms it moved more than `min` px sideways. The+ * rest's cap (the menu opens anyway after restCap) waits while it is, so a slow drift along the bar opens nothing.+ */+export function travelling(moves: readonly Move[], now: number, window = 150, min = 12): boolean {+ const recent = moves.filter((m) => now - m.t <= window);+ if (recent.length < 2) return false;+ return Math.abs(recent[recent.length - 1].x - recent[0].x) > min;+}+/* ----- The safe triangle: the pointer heading from an item into its open menu. ----- */export interface Pt {@@ -144,9 +159,10 @@ const inBox = (p: Pt, b: Box) => p.x >= b.left && p.x <= b.right && p.y >= b.top/*** The pointer is on its way into the open menu: inside the triangle from where it left the item (`exit`) to the menu's* two top corners (widened by `pad`), still moving (the last move under `stop` ms ago, faster than 0.05 px/ms) and- * downwards. `moves`: the last few pointer moves, oldest first.+ * downwards (at least `slope` px down per px across: a drift along the bar is not heading in). `moves`: the last few+ * pointer moves, oldest first.*/-export function aiming(exit: Pt | null, menu: Box | null, moves: readonly Move[], now: number, pad = 8, stop: number = NAV_INTENT.aimStop): boolean {+export function aiming(exit: Pt | null, menu: Box | null, moves: readonly Move[], now: number, pad = 8, stop: number = NAV_INTENT.aimStop, slope = 0.05): boolean {if (!exit || !menu || moves.length < 2) return false;const last = moves[moves.length - 1];const first = moves[0];@@ -154,7 +170,7 @@ export function aiming(exit: Pt | null, menu: Box | null, moves: readonly Move[]const dt = Math.max(1, last.t - first.t);const dx = last.x - first.x;const dy = last.y - first.y;- if (dy <= 0 || Math.hypot(dx, dy) / dt < 0.05) return false;+ if (dy <= 0 || dy < Math.abs(dx) * slope || Math.hypot(dx, dy) / dt < 0.05) return false;if (inBox(last, menu)) return true;return inTriangle(last, exit, { x: menu.left - pad, y: menu.top }, { x: menu.right + pad, y: menu.top });}diff --git a/src/lib/ui-motion.ts b/src/lib/ui-motion.tsindex d922880f..f17ca166 100644--- a/src/lib/ui-motion.ts+++ b/src/lib/ui-motion.ts@@ -358,8 +358,4 @@ export const NAV_INTENT = {aimStop: 60,/** A hover open waits at most this long for its menu's data. */dataWait: 150,- /** A loading menu shows its skeleton only after this long. */- skeletonGrace: 150,- /** The dimmed page starts to fade only once nothing has been open this long. */- scrimHold: 120,} as const;diff --git a/tests/bar-intent.test.ts b/tests/bar-intent.test.tsindex 037bd2f6..a0fae750 100644--- a/tests/bar-intent.test.ts+++ b/tests/bar-intent.test.ts@@ -9,6 +9,7 @@ import {restStart,switchDirection,switchesAtOnce,+ travelling,type BarMenuState,type Move,} from "@/lib/bar-intent";@@ -40,12 +41,16 @@ describe("the menu state", () => {expect(barMenus(closed, { type: "close", now: 20 })).toBe(closed);});- it("a click opens pinned, pins a menu the pointer opened (never closes it), and closes a pinned one", () => {+ it("a mouse click never pins: on a menu the pointer opened it only marks it clicked; the next click closes it", () => {const hover = open(CLOSED_MENUS, "create");- const pinned = barMenus(hover, { type: "click", id: "create", via: "pointer", now: 30 });- expect(pinned).toMatchObject({ id: "create", mode: "pinned" });- const closed = barMenus(pinned, { type: "click", id: "create", via: "pointer", now: 60 });+ const clicked = barMenus(hover, { type: "click", id: "create", via: "pointer", now: 30 });+ expect(clicked).toMatchObject({ id: "create", mode: "hover", clicked: true });+ const closed = barMenus(clicked, { type: "click", id: "create", via: "pointer", now: 60 });expect(closed.id).toBeNull();+ // From nothing, a mouse click opens it as a hover does (it closes once the mouse leaves).+ expect(barMenus(CLOSED_MENUS, { type: "click", id: "apps", via: "pointer", now: 0 })).toMatchObject({ id: "apps", mode: "hover", clicked: true });+ // A tap on a menu the pointer opened pins it.+ expect(barMenus(hover, { type: "click", id: "create", via: "touch", now: 30 })).toMatchObject({ id: "create", mode: "pinned", clicked: true });const fresh = barMenus(CLOSED_MENUS, { type: "click", id: "more", via: "touch", now: 0 });expect(fresh).toMatchObject({ id: "more", mode: "pinned", via: "touch" });// A click on another item while one is open switches to it, pinned.@@ -53,14 +58,14 @@ describe("the menu state", () => {});it("a click on a menu reached by moving from a pinned one pins it; only a menu its own click opened closes", () => {- const pinned = barMenus(CLOSED_MENUS, { type: "click", id: "studios", via: "pointer", now: 0 });+ const pinned = barMenus(CLOSED_MENUS, { type: "click", id: "studios", via: "touch", now: 0 });expect(pinned.clicked).toBe(true);// Onto Apps with the pointer: it takes over, pinned (a menubar), but not by its own click.const moved = open(pinned, "apps", "pinned");expect(moved).toMatchObject({ id: "apps", mode: "pinned", clicked: false });- const click1 = barMenus(moved, { type: "click", id: "apps", via: "pointer", now: 10 });+ const click1 = barMenus(moved, { type: "click", id: "apps", via: "touch", now: 10 });expect(click1).toMatchObject({ id: "apps", mode: "pinned", clicked: true });- expect(barMenus(click1, { type: "click", id: "apps", via: "pointer", now: 20 }).id).toBeNull();+ expect(barMenus(click1, { type: "click", id: "apps", via: "touch", now: 20 }).id).toBeNull();// A key open counts as the item's own (Enter next closes it).const key = barMenus(CLOSED_MENUS, { type: "open", id: "canvas", mode: "pinned", via: "key", clicked: true, now: 0 });expect(barMenus(key, { type: "click", id: "canvas", via: "key", now: 5 }).id).toBeNull();@@ -162,8 +167,26 @@ describe("the safe triangle", () => {expect(aiming(exit, card, path([[110, 36, 0], [120, 38, 16], [130, 40, 32]]), 32 + NAV_INTENT.aimStop + 1)).toBe(false);});+ it("holds for a shallow line into a wide panel, not for a drift along the bar", () => {+ // Studios to its far-right column: 1000 px across, 270 down.+ const panel = { left: 0, top: 56, right: 1440, bottom: 700 };+ const from = { x: 330, y: 30 };+ expect(aiming(from, panel, path([[340, 33, 0], [380, 44, 16], [420, 55, 32]]), 40)).toBe(true);+ // Along the bar with a slight sag: switches at once.+ expect(aiming(from, panel, path([[340, 30, 0], [380, 31, 16], [420, 32, 32]]), 40)).toBe(false);+ });+it("is off without an exit point or a menu", () => {expect(aiming(null, card, path([[110, 36, 0], [130, 40, 32]]), 40)).toBe(false);expect(aiming(exit, null, path([[110, 36, 0], [130, 40, 32]]), 40)).toBe(false);});});++describe("travelling: a drift along the bar", () => {+ const at = (pts: [number, number][]) => pts.map(([x, t]) => ({ x, y: 30, t }));+ it("is on while the pointer keeps moving sideways (200 px/s), off once it settles", () => {+ expect(travelling(at([[100, 0], [103, 16], [106, 32], [110, 48], [113, 64], [116, 80], [119, 96]]), 100)).toBe(true);+ expect(travelling(at([[100, 0], [102, 40], [103, 80], [104, 120]]), 130)).toBe(false);+ expect(travelling(at([[100, 0], [140, 16]]), 400)).toBe(false);+ });+});diff --git a/tests/e2e/bar-menus.mjs b/tests/e2e/bar-menus.mjsindex 2338b06b..80a66d23 100644--- a/tests/e2e/bar-menus.mjs+++ b/tests/e2e/bar-menus.mjs@@ -279,6 +279,7 @@ try {[1500, 0],[600, 0],[300, 1],+ [200, 1],]) {await away(p);await glide(p, { x: wm.x, y: wm.y }, Infinity);@@ -291,6 +292,20 @@ try {const opens = fs.filter((f, i) => i && f.open.length && !fs[i - 1].open.length).length;check(opens <= most, `5: a glide from the wordmark to search at ${speed} px/s opens ${most ? "at most one menu" : "nothing"}`, `${opens}: ${[...new Set(fs.flatMap((f) => f.open))].join()}`);}+ // A slow drift along the widest item (150 px/s, longer than the rest's 600 ms cap): nothing opens while it moves.+ {+ await away(p);+ const mo = await item(p, "motions");+ // From the bar just under it, so the pointer comes onto the item already moving.+ await glide(p, { x: mo.left + 6, y: mo.bottom + 6 }, Infinity);+ await sleep(300);+ await mark(p);+ const t0 = await pageNow(p);+ await glide(p, { x: mo.right - 4, y: mo.y }, (mo.w - 8) / 0.9);+ const t1 = await pageNow(p);+ const fs = await frames(p);+ check(!fs.some((f) => f.t >= t0 && f.t <= t1 && f.open.length), `5: a slow drift across Motions & effects (${((mo.w - 8) / 0.9).toFixed(0)} px/s for 900 ms) opens nothing while it moves`);+ }// 6. With Studios open, away along the bar to search: one close, the dimmed page fades once.await away(p);const st = await item(p, "studios");@@ -365,6 +380,41 @@ try {fs = await frames(p);const crossed = await arrive(p);check(fs.every((f) => f.open.join() === "create"), "8: Create → its right column across the Studios item: no switch, no close", `crossed Studios: ${crossed.studios != null}; ${[...new Set(fs.map((f) => f.open.join()))].join(" / ")}`);+ // Straight lines from the middle of an item to its menu's far rows, fast and slow, at 1440 and 1280.+ for (const vp of [{ width: 1440, height: 900 }, { width: 1280, height: 720 }]) {+ await p.setViewportSize(vp);+ await sleep(300);+ const lines = [+ ["create", async () => {+ const c = await rect(p, '[data-bar-card="create"] > div');+ const r1 = await rect(p, '[data-bar-card="create"] [data-col="1"][data-row="0"]');+ return { x: r1?.x ?? c.right - 60, y: c.top + 14 };+ }],+ ["studios", async () => ({ x: vp.width - 120, y: 300 })],+ ["studios", async () => {+ const it = await item(p, "studios");+ const pn = await rect(p, '[data-mega-panel="studios"]');+ return { x: it.x + 260, y: pn.top + 24 };+ }],+ ];+ for (const [id, target] of lines) {+ for (const speed of [700, 1500]) {+ await away(p);+ const it = await item(p, id);+ await glide(p, { x: it.x, y: it.y }, Infinity);+ await p.waitForFunction((id) => window.__bmState().open.includes(id), id, { timeout: 2000 });+ await sleep(250);+ const to = await target();+ await mark(p);+ await glide(p, to, speed);+ await sleep(400);+ fs = await frames(p);+ const seen = [...new Set(fs.map((f) => f.open.join()))].join(" / ");+ check(fs.every((f) => f.open.join() === id), `8: ${vp.width} ${id} → (${to.x.toFixed(0)}, ${to.y.toFixed(0)}) at ${speed} px/s: no switch, no close`, seen);+ }+ }+ }+ await p.setViewportSize({ width: 1440, height: 900 });await ctx.close();}@@ -396,21 +446,30 @@ try {await sleep(delay);await mark(p);await p.mouse.click(r.x, r.y);+ await sleep(250);+ const fs = await frames(p);+ check(fs.every((f) => f.open.includes("studios")), `9 (A): a click ${delay} ms after a hover open keeps it open (never closes it)`);+ // The mouse never pins: leaving closes it as for any hover menu (Stripe, Vercel, Apple).await glide(p, { x: 700, y: 895 }, Infinity);await sleep(800);- const fs = await frames(p);- check(fs.every((f) => f.open.includes("studios")), `9 (A): a click ${delay} ms after a hover open pins it (never closes); leaving keeps it`);- await p.mouse.click(r.x, r.y);- await sleep(200);+ check(!(await now(p)).open.length, `9 (A): after that click, leaving with the mouse closes it`);}// A click during the rest wait opens it, pinned.await away(p);const ap = await item(p, "apps");await glide(p, { x: ap.x, y: ap.y }, Infinity);await p.mouse.click(ap.x, ap.y);- await glide(p, { x: 700, y: 895 }, Infinity);- await sleep(800);- check((await now(p)).open.join() === "apps", "9 (A): a click during the rest wait opens it pinned");+ await sleep(250);+ check((await now(p)).open.join() === "apps", "9 (A): a click during the rest wait opens it");+ await p.mouse.click(ap.x, ap.y);+ await sleep(250);+ check(!(await now(p)).open.length, "9 (A): the next click on it closes it");+ // A double click counts once: the menu stays open.+ await away(p);+ await glide(p, { x: ap.x, y: ap.y }, Infinity);+ await p.mouse.dblclick(ap.x, ap.y);+ await sleep(300);+ check((await now(p)).open.join() === "apps", "9 (A): a double click on an item leaves its menu open");await p.keyboard.press("Escape");await sleep(200);// Ctrl-click: the area's page in a new tab; the menu state does not change (here: Studios, opened by resting on it).@@ -703,6 +762,106 @@ try {await ctx.close();}+ // ---------- 20. Typing elsewhere keeps its keys; 21. a resize that hides the open item closes it; 22. switches+ // never show a panel past the sheet's edge; 23. Create's See all sits at the card's top right ----------+ {+ const ctx = await context();+ const p = await open(ctx);+ await away(p);+ await p.evaluate(() => {+ const t = document.createElement("textarea");+ t.id = "bm-prompt";+ t.style.cssText = "position:fixed;left:20px;bottom:20px;z-index:100;width:200px;height:40px";+ document.body.append(t);+ t.focus();+ });+ await p.keyboard.type("abc");+ for (const id of ["studios", "create"]) {+ const it = await item(p, id);+ await glide(p, { x: it.x, y: it.y }, Infinity);+ await p.waitForFunction((id) => window.__bmState().open.includes(id), id, { timeout: 2000 });+ const row = await rect(p, id === "create" ? '[data-bar-card="create"] [data-col="0"][data-row="1"]' : '[data-mega-panel="studios"] [data-col="1"][data-row="1"]');+ await glide(p, { x: row.x, y: row.y }, 900);+ await sleep(200);+ const during = await p.evaluate(() => document.activeElement?.id);+ await glide(p, { x: 700, y: 880 }, 1500);+ await sleep(700);+ await p.keyboard.type("d");+ const v = await p.evaluate(() => ({ id: document.activeElement?.id, v: document.getElementById("bm-prompt").value }));+ check(during === "bm-prompt" && v.id === "bm-prompt" && v.v === "abcd", `20: passing over ${id}'s rows while typing keeps focus and keys in the field`, `${during} / ${v.id} / ${v.v}`);+ await p.evaluate(() => (document.getElementById("bm-prompt").value = "abc"));+ }+ await p.evaluate(() => document.getElementById("bm-prompt").remove());++ // 21. Canvas shows only from 1440: open it, narrow the window, the menu closes and no highlight is left.+ await away(p);+ const cv = await item(p, "canvas");+ await glide(p, { x: cv.x, y: cv.y }, Infinity);+ await p.mouse.click(cv.x, cv.y);+ await p.waitForFunction(() => window.__bmState().open.includes("canvas"), null, { timeout: 2000 });+ await p.setViewportSize({ width: 1300, height: 900 });+ await sleep(500);+ const after = await p.evaluate(() => ({ open: window.__bmState().open, on: document.querySelector("[data-bar-indicator]")?.hasAttribute("data-on") }));+ check(!after.open.length && !after.on, "21: a resize that hides Canvas closes its menu, with no highlight left on the bar", JSON.stringify(after));+ // (The pointer off the bar first: Canvas comes back under it otherwise, and a rest there opens it.)+ await glide(p, { x: 700, y: 880 }, Infinity);+ await p.setViewportSize({ width: 1440, height: 900 });+ await sleep(400);+ check(!(await now(p)).open.length, "21: back to 1440, it stays closed");++ // 22. Between two big panels the painted part of each one ends at the sheet's edge (never text on the bare page).+ for (const [a, b] of [["apps", "studios"], ["studios", "apps"], ["canvas", "motions"], ["apps", "motions"]]) {+ await away(p);+ const ra = await item(p, a);+ const rb = await item(p, b);+ await glide(p, { x: ra.x, y: ra.y }, Infinity);+ await p.waitForFunction((a) => window.__bmState().open.includes(a), a, { timeout: 2000 });+ await sleep(400);+ const watch = p.evaluate(async () => {+ let worst = 0;+ let both = 0;+ const end = performance.now() + 500;+ while (performance.now() < end) {+ const sheet = document.querySelector("[data-mega-sheet]").getBoundingClientRect();+ let shown = 0;+ for (const s of document.querySelectorAll("[data-mega-panel]:not([hidden])")) {+ const cs = getComputedStyle(s);+ const op = Number(cs.opacity);+ if (op < 0.05) continue;+ if (op > 0.3) shown++;+ const r = s.getBoundingClientRect();+ // The cut at its bottom: inset's third length, a calc of the panel's own height (100%) while it moves.+ const inset = /^inset\(0px 0px (.+?)(?: 0px)?\)$/.exec(cs.clipPath)?.[1] ?? "0px";+ const js = inset.replaceAll("100%", `${r.height}px`).replaceAll("px", "").replaceAll("max(", "Math.max(").replaceAll("calc(", "(");+ const cut = Number(Function(`return (${js})`)()) || 0;+ const bottom = r.bottom - cut;+ worst = Math.max(worst, bottom - sheet.bottom);+ }+ if (shown > 1) both++;+ await new Promise(requestAnimationFrame);+ }+ return { worst, both };+ });+ await sleep(30);+ await glide(p, { x: rb.x, y: rb.y }, Infinity);+ const w = await watch;+ check(w.worst <= 2, `22: ${a} → ${b}: no panel shows past the sheet's edge during the switch`, `${w.worst.toFixed(0)} px`);+ check(w.both <= 1, `22: ${a} → ${b}: never two panels' words clearly at once`, `${w.both} frames`);+ }++ // 23. Create's See all: top right of the card, out of the rows' flow.+ await away(p);+ const cr = await item(p, "create");+ await glide(p, { x: cr.x, y: cr.y }, Infinity);+ await p.waitForFunction(() => window.__bmState().open.includes("create"), null, { timeout: 2000 });+ await sleep(300);+ const sa = await rect(p, '[data-bar-card="create"] [data-see-all]');+ const card = await rect(p, '[data-bar-card="create"] > div');+ const head = await rect(p, '[data-bar-card="create"] [role="group"]');+ check(!!sa && !!card && !!head && card.right - sa.right <= 12 && sa.top - card.top <= 12 && head.top - card.top <= 12, "23: Create's See all sits at the card's top right; the headings start at the top", JSON.stringify({ sa, card: card && { top: card.top, right: card.right }, head: head?.top }));+ await ctx.close();+ }+// ---------- 19. Phone ----------{const ctx = await context({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });diff --git a/tests/nav-bar.test.ts b/tests/nav-bar.test.tsindex 85feaa08..49c41c15 100644--- a/tests/nav-bar.test.ts+++ b/tests/nav-bar.test.ts@@ -452,7 +452,9 @@ describe("menu items: one button each, the area's page inside its menu", () => {}expect(item(html, "more")).toContain('aria-expanded="false"');expect(item(html, "more")).not.toContain("data-href");- expect(item(html, "studios")).toContain(`aria-label="Studios, ${studioCount()} studios"`);+ // Its spoken name starts with its visible words ("Studios, 29 studios"): the count's words are hidden text, not a label.+ expect(item(html, "studios")).not.toContain("aria-label=");+ expect(html).toMatch(new RegExp(`Studios<span class="sr-only">,</span><span[^>]*>${studioCount()}</span><span class="sr-only"> studios</span>`));// The Studios item is still the launcher's disclosure button (search hands focus back to it).expect(item(html, "studios")).toContain("data-studios-trigger");for (const name of ["Create menu", "Studios menu", "Apps menu", "Motions & effects menu", "Canvas menu"]) expect(html, name).not.toContain(`aria-label="${name}"`);diff --git a/tests/ui-motion.test.ts b/tests/ui-motion.test.tsindex 88277975..bf81f0a1 100644--- a/tests/ui-motion.test.ts+++ b/tests/ui-motion.test.ts@@ -67,8 +67,9 @@ describe("motion tokens", () => {for (const t of css.matchAll(/transition:\s*([^;]+);/g)) {for (const part of t[1].split(",")) {const prop = part.trim().split(/\s+/)[0];- // Sonner's own stack height and its focus shadow are kept from the library; background colour is a colour; none ends one at once.- expect(["none", "opacity", "translate", "scale", "transform", "display", "height", "box-shadow", "background-color"]).toContain(prop);+ // Sonner's own stack height and its focus shadow are kept from the library; background and border colours are+ // colours; a menu's cut (clip-path) only paints; none ends one at once.+ expect(["none", "opacity", "translate", "scale", "transform", "display", "height", "box-shadow", "background-color", "border-color", "clip-path"]).toContain(prop);}}});