From ce12dd31599e2a808c043e2d66e63fcf7d4511f0 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 7 Aug 2026 18:13:17 +0000 Subject: [PATCH] fix(ui): keep burger menu in universal phone header Stop swapping the top-left control to a back arrow on information pages and differentials search results. Page-owned back controls remain the navigation path; the universal bar stays mode, new chat, menu. --- .../global-search-shell.tsx | 45 ------------------- .../master-search-header.tsx | 18 ++------ tests/global-search-shell-back-href.test.ts | 39 ---------------- 3 files changed, 4 insertions(+), 98 deletions(-) delete mode 100644 tests/global-search-shell-back-href.test.ts diff --git a/src/components/clinical-dashboard/global-search-shell.tsx b/src/components/clinical-dashboard/global-search-shell.tsx index 186a0dac2c..285a8d7c77 100644 --- a/src/components/clinical-dashboard/global-search-shell.tsx +++ b/src/components/clinical-dashboard/global-search-shell.tsx @@ -260,30 +260,6 @@ function readInitialBrowserSubmittedSearchParamString(): string { return params.get("run") === "1" && query ? search : ""; } -export function infoPageBackHref(pathname: string): string | null { - if (pathname.startsWith("/services/")) return appModeHomeHref("services"); - if (pathname.startsWith("/forms/")) return appModeHomeHref("forms"); - if (pathname.startsWith("/medications/")) return appModeHomeHref("prescribing"); - if (pathname.startsWith("/differentials/")) return appModeHomeHref("differentials"); - if (pathname.startsWith("/dsm/")) return appModeHomeHref("dsm"); - if (pathname.startsWith("/specifiers/")) return appModeHomeHref("specifiers"); - if (pathname.startsWith("/formulation/")) return appModeHomeHref("formulation"); - if (pathname.startsWith("/therapy-compass/")) return appModeHomeHref("therapy-compass"); - if (pathname.startsWith("/factsheets/")) return appModeHomeHref("factsheets"); - if (pathname.startsWith("/documents/")) return documentsSearchHref(); - return null; -} - -/** Stable in-app back target for non-info mobile back (e.g. submitted differential search). */ -export function mobileBackHref(pathname: string, searchMode: string, hasQuery: boolean): string | null { - const infoHref = infoPageBackHref(pathname); - if (infoHref) return infoHref; - if (pathname === "/differentials" && searchMode === "differentials" && hasQuery) { - return appModeHomeHref("differentials", { focus: true }); - } - return null; -} - function isToolDetailWithFooterSearch(pathname: string): boolean { return ( (pathname.startsWith("/services/") && pathname !== "/services") || @@ -864,27 +840,6 @@ function GlobalStandaloneSearchShellBody({ onNewChat={startNewAnswerChat} showDesktopNewChat={!shouldShowDesktopSidebar} onOpenMobileSidebar={() => setMobileMenuOpen(true)} - mobileLeadingAction={ - isInfoPage - ? "back" - : pathname === "/differentials" && searchMode === "differentials" && requestedQuery - ? "back" - : "menu" - } - onMobileBack={() => { - const fallbackHref = mobileBackHref(pathname, searchMode, Boolean(requestedQuery)); - if (fallbackHref) { - if (!isInfoPage) setQuery(""); - router.push(fallbackHref); - return; - } - if (!isInfoPage) { - setQuery(""); - navigateToMode(searchMode, { focus: true }); - return; - } - router.back(); - }} queryModeOptions={mockupQueryModeOptions} queryInputRef={inputRef} recentQueries={recentQueries} diff --git a/src/components/clinical-dashboard/master-search-header.tsx b/src/components/clinical-dashboard/master-search-header.tsx index 31c32d47aa..17d59eabdd 100644 --- a/src/components/clinical-dashboard/master-search-header.tsx +++ b/src/components/clinical-dashboard/master-search-header.tsx @@ -29,7 +29,6 @@ import { Search, Send, ShieldCheck, - ArrowLeft, X, } from "lucide-react"; @@ -197,8 +196,6 @@ export function MasterSearchHeader({ desktopPageComposerSlotId, heroComposerBreakpoint = "all", mobileBottomSearchAddonSlotId, - mobileLeadingAction = "menu", - onMobileBack, hideOnScroll, onBottomComposerHiddenChange, showDesktopNewChat = true, @@ -263,8 +260,6 @@ export function MasterSearchHeader({ heroComposerBreakpoint?: "all" | "sm-up"; /** Mobile/tablet slot rendered above the search pill for page-specific composer addons. */ mobileBottomSearchAddonSlotId?: string; - mobileLeadingAction?: "menu" | "back"; - onMobileBack?: () => void; /** Phone-only hide-on-scroll for the universal header and bottom search dock. * "overlay" translates the sticky header away (host scrolls the document, * content already flows beneath); "collapse" also releases the header's @@ -604,7 +599,6 @@ export function MasterSearchHeader({ : "answer"; const actionMenuItems = modeActionItemsFor(actionMenuSetId); const actionMenuButtonLabel = `Open ${selectedAppMode.label.toLowerCase()} options`; - const useMobileBackControl = mobileLeadingAction === "back"; function currentUsesScopeSheet() { return window.matchMedia(scopeSheetMediaQuery).matches; @@ -2031,20 +2025,16 @@ export function MasterSearchHeader({
{isServicesMode ? (
diff --git a/tests/global-search-shell-back-href.test.ts b/tests/global-search-shell-back-href.test.ts deleted file mode 100644 index cfe16fa623..0000000000 --- a/tests/global-search-shell-back-href.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { describe, expect, it } from "vitest"; - -import { infoPageBackHref, mobileBackHref } from "@/components/clinical-dashboard/global-search-shell"; - -describe("infoPageBackHref", () => { - it.each([ - ["/services/community-team", "/services"], - ["/forms/12a", "/forms"], - ["/medications/lithium", "/?mode=prescribing"], - ["/differentials/diagnoses/delirium", "/differentials"], - ["/dsm/diagnoses/delirium", "/dsm"], - ["/specifiers/anxious-distress", "/specifiers"], - ["/formulation/example", "/formulation"], - ["/therapy-compass/cbt/brief", "/therapy-compass"], - ["/factsheets/lithium", "/factsheets"], - ["/documents/example", "/documents/search?mode=documents"], - ])("maps %s to its stable in-app parent", (pathname, expected) => { - expect(infoPageBackHref(pathname)).toBe(expected); - }); - - it("leaves non-detail routes on browser-history behaviour", () => { - expect(infoPageBackHref("/services")).toBeNull(); - expect(infoPageBackHref("/privacy")).toBeNull(); - }); -}); - -describe("mobileBackHref", () => { - it("routes submitted differential search back to the differentials home with focus", () => { - expect(mobileBackHref("/differentials", "differentials", true)).toBe("/differentials?focus=1"); - }); - - it("does not invent a target for non-submitted differential home visits", () => { - expect(mobileBackHref("/differentials", "differentials", false)).toBeNull(); - }); - - it("still prefers info-page parents over mode-home fallbacks", () => { - expect(mobileBackHref("/differentials/diagnoses/delirium", "differentials", true)).toBe("/differentials"); - }); -});