Skip to content

armgit / fuobe

Public Imported from GitHub
0

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.

Bar menus: always a way out (page in view under the panel, a close button)

Adarshc44d5dd27e6f
diff --git a/src/components/nav/mega-launcher.tsx b/src/components/nav/mega-launcher.tsx
index ca97e158..7cc63969 100644
--- a/src/components/nav/mega-launcher.tsx
+++ b/src/components/nav/mega-launcher.tsx
@@ -38,9 +38,11 @@ export function launcherCurrent(pathname: string): string | undefined {
/**
* The panel: under the bar, as wide as it, on the bar's shared sheet (it has no background of its own, so a switch
- * cross-fades two panels over one surface); scrolling inside only when the window is too short for it.
+ * cross-fades two panels over one surface); scrolling inside when its tiles don't fit. It always stops 72 px short of
+ * the window's bottom, so some of the page shows under it: the way out for a pointer (resting there closes a menu the
+ * pointer opened) and for a click (anywhere there closes any menu).
*/
-export const LAUNCHER_PANEL = "absolute inset-x-0 top-full max-h-[calc(100dvh-3.5rem)] overflow-y-auto overscroll-contain text-popover-foreground";
+export const LAUNCHER_PANEL = "absolute inset-x-0 top-full max-h-[calc(100dvh-3.5rem-72px)] overflow-y-auto overscroll-contain text-popover-foreground";
/** The routes a menu's links lead to that load ahead when it opens (each row also loads on hover: IntentLink). */
const WARM: Record<MegaId, NavPanel> = { create: "create", studios: "studios", apps: "more", motions: "more", canvas: "more", fx: "fx" };
@@ -203,6 +205,8 @@ export function MegaLauncher({ id, active, className }: { id: MegaId; active?: b
searchRef.current = search;
});
const onClose = useCallback(() => closeRef.current(), []);
+ // The panel's own close button: closes it and gives focus back to its item.
+ const onDismiss = useCallback(() => closeRef.current(true), []);
const onSearch = useCallback(() => {
// The item gets focus first, so it is where Esc in the search comes back to (the panel is gone by then).
closeRef.current(true);
@@ -259,6 +263,7 @@ export function MegaLauncher({ id, active, className }: { id: MegaId; active?: b
id={id}
onPrimed={onPrimed}
onClose={onClose}
+ onDismiss={onDismiss}
onSearch={onSearch}
/>
</Suspense>
diff --git a/src/components/nav/mega-panel.tsx b/src/components/nav/mega-panel.tsx
index 42f42e88..22c9ebba 100644
--- a/src/components/nav/mega-panel.tsx
+++ b/src/components/nav/mega-panel.tsx
@@ -1,6 +1,6 @@
"use client";
-import { ArrowRight, ChevronRight, Plus, RotateCw, Search } from "lucide-react";
+import { ArrowRight, ChevronRight, Plus, RotateCw, Search, X } from "lucide-react";
import { usePathname, useSearchParams } from "next/navigation";
import { Fragment, lazy, memo, Suspense, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
import { IntentLink } from "@/components/intent-link";
@@ -343,8 +343,9 @@ function decodePictures(root: HTMLElement, cap = 4000): Promise<void> {
/**
* The panel's body once it is shown or warmed: it reads the path (client only: the panel never renders on the server).
* `onPrimed`: its menu is here and its first screen's pictures are decoded (a hover open waits a moment for it).
+ * `onDismiss`: its close button (focus goes back to its bar item).
*/
-export function MegaPanel({ id, onClose, onSearch, onPrimed }: { id: MegaId; onClose: () => void; onSearch: () => void; onPrimed?: () => void }) {
+export function MegaPanel({ id, onClose, onDismiss, onSearch, onPrimed }: { id: MegaId; onClose: () => void; onDismiss?: () => void; onSearch: () => void; onPrimed?: () => void }) {
const kind = useViewerKind();
const pathname = usePathname();
const { model, failed, retry } = useMegaMenu(id, kind);
@@ -429,6 +430,16 @@ export function MegaPanel({ id, onClose, onSearch, onPrimed }: { id: MegaId; onC
/
</Kbd>
</button>
+ {/* The plain way out, always in view (Esc, a click on the page under the panel and moving off it work too). */}
+ <button
+ type="button"
+ onClick={onDismiss ?? onClose}
+ aria-label="Close menu"
+ title="Close (Esc)"
+ className="nav-row -mr-2 grid size-10 shrink-0 place-items-center rounded-full text-muted-foreground hover:text-foreground [@media(pointer:coarse)]:size-11"
+ >
+ <X aria-hidden className="size-5" />
+ </button>
</div>
{model ? <MegaGrid model={model} kind={kind} current={megaCurrent(id, pathname, search)} now={now} /> : failed ? null : <MegaSkeleton id={id} />}
</div>