fix(web): show sidebar hints only on the icon rail, above the main area (UF-042)
With the full-width sidebar every item showed a hover hint that repeated its visible label, and the part of the hint that reached past the sidebar was hidden wherever the main area had content: the hint rendered inside the nav, and the nav and <main> are sibling z-10 layers. Sidebar hints now show only on the icon rail below lg, where they are the only label, and render in document.body through a new opt-in `portal` flag on HintTooltip. Other hints keep rendering in place, since several sit in overlays above z-50 where a portaled hint would end up underneath.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { ElementType } from "react";
|
||||
import type { ElementType, ReactElement } from "react";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import { ChevronDown, Plus, Search } from "lucide-react";
|
||||
import { cmdKLabel } from "@/lib/platform";
|
||||
@@ -50,6 +50,15 @@ function initialOf(name: string | null, fallback: string): string {
|
||||
return (c ?? fallback).toUpperCase();
|
||||
}
|
||||
|
||||
/** Every label is visible at ≥lg, so the hover hint shows only on the icon rail
|
||||
* below lg, where it is the only way to read the label. Portaled: <main> is a
|
||||
* sibling z-10 layer and paints over anything inside the nav (UF-042). */
|
||||
const RailHint = ({ content, children }: { content: string; children: ReactElement }) => (
|
||||
<HintTooltip content={content} side="right" portal className="lg:hidden">
|
||||
{children}
|
||||
</HintTooltip>
|
||||
);
|
||||
|
||||
const Sidebar = ({
|
||||
workspaceName,
|
||||
spine,
|
||||
@@ -71,9 +80,7 @@ const Sidebar = ({
|
||||
const active = isActive(item);
|
||||
const Icon = item.icon;
|
||||
return (
|
||||
// Below lg the sidebar collapses to an icon rail — the hover tooltip is the
|
||||
// only way to read the label there. It's redundant (but harmless) at ≥lg.
|
||||
<HintTooltip key={item.key} content={item.label} side="right">
|
||||
<RailHint key={item.key} content={item.label}>
|
||||
<button
|
||||
data-testid={`nav-${item.key}`}
|
||||
aria-label={item.label}
|
||||
@@ -102,7 +109,7 @@ const Sidebar = ({
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
</HintTooltip>
|
||||
</RailHint>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -124,7 +131,7 @@ const Sidebar = ({
|
||||
className="waggle-sidebar relative z-10 flex w-16 lg:w-[248px] shrink-0 flex-col gap-1 overflow-y-auto border-r border-[var(--line-soft)] bg-[var(--bg-2)] px-2 lg:px-3 py-3.5"
|
||||
>
|
||||
{/* Workspace switcher pill */}
|
||||
<HintTooltip content={workspaceName ?? "Workspace"} side="right">
|
||||
<RailHint content={workspaceName ?? "Workspace"}>
|
||||
<button
|
||||
data-testid="sidebar-workspace"
|
||||
aria-label="Switch workspace"
|
||||
@@ -145,7 +152,7 @@ const Sidebar = ({
|
||||
</span>
|
||||
<ChevronDown className="hidden h-4 w-4 shrink-0 text-[var(--text-dim)] lg:block" />
|
||||
</button>
|
||||
</HintTooltip>
|
||||
</RailHint>
|
||||
|
||||
{/* Five-place calm spine */}
|
||||
{spine.map(renderNavItem)}
|
||||
@@ -160,7 +167,7 @@ const Sidebar = ({
|
||||
|
||||
{/* General → ⌘K */}
|
||||
<div className={zoneLabel}>General</div>
|
||||
<HintTooltip content={`Search & commands (${cmdKLabel})`} side="right">
|
||||
<RailHint content={`Search & commands (${cmdKLabel})`}>
|
||||
<button
|
||||
data-testid="sidebar-command"
|
||||
aria-label="Search and commands"
|
||||
@@ -173,10 +180,10 @@ const Sidebar = ({
|
||||
{cmdKLabel}
|
||||
</kbd>
|
||||
</button>
|
||||
</HintTooltip>
|
||||
</RailHint>
|
||||
|
||||
{/* New agent — primary spawn affordance (also reachable from ⌘K) */}
|
||||
<HintTooltip content="New Agent" side="right">
|
||||
<RailHint content="New Agent">
|
||||
<button
|
||||
data-testid="nav-spawn-agent"
|
||||
aria-label="New Agent"
|
||||
@@ -186,12 +193,12 @@ const Sidebar = ({
|
||||
<Plus className="h-[18px] w-[18px] shrink-0" strokeWidth={1.8} />
|
||||
<span className="hidden flex-1 text-[13px] font-semibold lg:inline">New Agent</span>
|
||||
</button>
|
||||
</HintTooltip>
|
||||
</RailHint>
|
||||
|
||||
<div className="flex-1" />
|
||||
|
||||
{/* User row → Settings */}
|
||||
<HintTooltip content={userName ?? "Account"} side="right">
|
||||
<RailHint content={userName ?? "Account"}>
|
||||
<button
|
||||
data-testid="sidebar-user"
|
||||
aria-label="Account and settings"
|
||||
@@ -207,7 +214,7 @@ const Sidebar = ({
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
</HintTooltip>
|
||||
</RailHint>
|
||||
</nav>
|
||||
</TooltipProvider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user