Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix(sidebar): open the navigator label only where the row can afford it
johnnyjoygh88f150502c9a
diff --git a/web/src/components/AppSidebar/AppSidebar.tsx b/web/src/components/AppSidebar/AppSidebar.tsxindex 5c63b0296..7831287c0 100644--- a/web/src/components/AppSidebar/AppSidebar.tsx+++ b/web/src/components/AppSidebar/AppSidebar.tsx@@ -310,22 +310,28 @@ interface GlobalNavItem {/*** The compact navigator is intentionally horizontal. Its 16px glyph plus 6px padding* on each side makes the collapsed control an exact 28px square, the same box as the- * header's compose control. Expanding the- * label only opens the text track, so the artwork and surface never jump.+ * header's compose control. Expanding the label only opens the text track, so the+ * artwork and surface never jump.+ *+ * The label is a luxury the row affords by width, never by truncation. Five squares and+ * their gaps cost 148px and the longest label 82px more, so below a 230px row (the default+ * sidebar's content box) the current page stays a filled square with its tooltip.*/+const NAV_LABEL_QUERY = "@min-[230px]:";const navPillClasses = (active: boolean) =>cn(sidebarSurfaceVariants({ role: "navPill" }), SIDEBAR_ROW_FOCUS_CLASSES, sidebarRowStateClasses(active ? "current" : "idle"));const NavPillLabel = ({ expanded, label, children }: { expanded: boolean; label: ReactNode; children?: ReactNode }) => (+ // The control carries its own aria-label; this text is decoration whether or not it is open.<span- aria-hidden={!expanded || undefined}+ aria-hidden="true"className={cn(- "grid min-w-0 transition-[grid-template-columns,padding] duration-200 ease-out motion-reduce:transition-none",- expanded ? "grid-cols-[1fr] ps-2.5" : "grid-cols-[0fr] ps-0",+ "grid min-w-0 grid-cols-[0fr] ps-0 transition-[grid-template-columns,padding] duration-200 ease-out motion-reduce:transition-none",+ expanded && `${NAV_LABEL_QUERY}grid-cols-[1fr] ${NAV_LABEL_QUERY}ps-2`,)}><span className="flex min-w-0 items-center gap-1.5 overflow-hidden">- <span data-sidebar-label className="max-w-[5.5rem] shrink-0 truncate text-[12px]">+ <span data-sidebar-label className="shrink-0 truncate text-[12px]">{label}</span>{children}@@ -440,7 +446,7 @@ const GlobalNavigation = () => {return (<TooltipProvider>- <nav className={cn("flex h-7 items-center gap-1", SIDEBAR_RAIL_CLASSES)} aria-label="Primary">+ <nav className={cn("@container flex h-7 items-center gap-0.5", SIDEBAR_RAIL_CLASSES)} aria-label="Primary">{currentUser && (<DropdownMenuonOpenChange={(open, eventDetails) => {diff --git a/web/src/components/AppSidebar/SidebarRow.tsx b/web/src/components/AppSidebar/SidebarRow.tsxindex a931579f3..8f32a5256 100644--- a/web/src/components/AppSidebar/SidebarRow.tsx+++ b/web/src/components/AppSidebar/SidebarRow.tsx@@ -1,5 +1,6 @@import type { LucideIcon } from "lucide-react";import type { ReactNode } from "react";+import { FOCUS_VISIBLE_OUTLINE_CLASSES } from "@/components/ui/focus";import { cn } from "@/lib/utils";import { SIDEBAR_LEADING_SLOT_CLASSES, sidebarSurfaceVariants } from "./sidebar-layout";@@ -13,8 +14,7 @@ import { SIDEBAR_LEADING_SLOT_CLASSES, sidebarSurfaceVariants } from "./sidebar-export const SIDEBAR_ROW_BOX_CLASSES = `${sidebarSurfaceVariants({ role: "row" })} group transition-colors`;/** Goes on whichever element in a row actually takes focus. */-export const SIDEBAR_ROW_FOCUS_CLASSES =- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/50";+export const SIDEBAR_ROW_FOCUS_CLASSES = FOCUS_VISIBLE_OUTLINE_CLASSES;export const SIDEBAR_ROW_CLASSES = `${SIDEBAR_ROW_BOX_CLASSES} ${SIDEBAR_ROW_FOCUS_CLASSES}`;diff --git a/web/tests/app-sidebar-logo.test.tsx b/web/tests/app-sidebar-logo.test.tsxindex 80770e78f..d270f138a 100644--- a/web/tests/app-sidebar-logo.test.tsx+++ b/web/tests/app-sidebar-logo.test.tsx@@ -166,6 +166,7 @@ const expectCollapsedNavPill = (pill: HTMLElement, label: string) => {expect(pill.firstElementChild).toHaveClass("size-4");const labelTrack = pill.querySelector('span.grid[aria-hidden="true"]');expect(labelTrack).toHaveClass("grid-cols-[0fr]", "ps-0");+ expect(labelTrack).not.toHaveClass("@min-[230px]:grid-cols-[1fr]");expect(labelTrack).toHaveTextContent(label);};@@ -173,8 +174,9 @@ const expectExpandedNavPill = (pill: HTMLElement, label: string) => {expect(pill).toHaveClass("h-7", "rounded-md", "px-1.5");expect(pill.firstElementChild).toHaveClass("size-4");const labelTrack = pill.querySelector("span.grid");- expect(labelTrack).toHaveClass("grid-cols-[1fr]", "ps-2.5");- expect(labelTrack).not.toHaveAttribute("aria-hidden");+ // The label opens only where the row can afford it; the control's aria-label names it regardless.+ expect(labelTrack).toHaveClass("@min-[230px]:grid-cols-[1fr]", "@min-[230px]:ps-2");+ expect(labelTrack).toHaveAttribute("aria-hidden", "true");expect(pill.querySelector("[data-sidebar-label]")).toHaveTextContent(label);};@@ -416,7 +418,7 @@ describe("App sidebar logo", () => {expect(screen.getByRole("link", { name: "Memos logo" })).toHaveAttribute("href", "/explore");expect(screen.queryByRole("button", { name: /^space\.switch:/ })).not.toBeInTheDocument();const primaryNavigation = screen.getByRole("navigation", { name: "Primary" });- expect(primaryNavigation).toHaveClass("h-7", "items-center", "gap-1", "px-3");+ expect(primaryNavigation).toHaveClass("h-7", "items-center", "gap-0.5", "px-3");expect(primaryNavigation).not.toHaveClass("flex-col");const navigation = within(primaryNavigation);expect(navigation.getByRole("button", { name: "common.search" })).toHaveClass("ms-auto", "h-7", "px-1.5");