Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-8782 fix(rail): show the full name when a rail label is cut off (#10133)

Jiayuan Zhang0404281d9deb
diff --git a/packages/views/layout/app-rail.test.tsx b/packages/views/layout/app-rail.test.tsx
index d3f0d33d24..7ef5442d7a 100644
--- a/packages/views/layout/app-rail.test.tsx
+++ b/packages/views/layout/app-rail.test.tsx
@@ -1,5 +1,5 @@
import type { ReactNode } from "react";
-import { act, fireEvent, screen } from "@testing-library/react";
+import { act, fireEvent, screen, within } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { useRailOrderStore } from "@multica/core/navigation";
@@ -181,6 +181,33 @@ describe("AppRail spaces", () => {
});
});
+describe("AppRail label disclosure", () => {
+ const tooltip = () => document.querySelector("[data-slot=tooltip-content]");
+
+ // jsdom does not lay out the rail: model a label too long for the item.
+ function clipLabel(el: HTMLElement) {
+ el.style.overflowX = "hidden";
+ Object.defineProperties(el, {
+ scrollWidth: { configurable: true, value: 90 },
+ clientWidth: { configurable: true, value: 44 },
+ });
+ }
+
+ it("names a space whose label is cut off even when it is already the full name", async () => {
+ renderRail();
+ const inbox = link("/acme/inbox")!;
+ clipLabel(within(inbox).getByText("Inbox"));
+ await act(async () => inbox.focus());
+ expect(tooltip()).toHaveTextContent("Inbox");
+ });
+
+ it("stays quiet when the full-name label fits", async () => {
+ renderRail();
+ await act(async () => link("/acme/inbox")!.focus());
+ expect(tooltip()).toBeNull();
+ });
+});
+
describe("AppRail badges", () => {
it("counts inbox unread with a static counter", () => {
state.inboxUnread = 4;
diff --git a/packages/views/layout/app-rail.tsx b/packages/views/layout/app-rail.tsx
index adf1d0250d..ddc178d295 100644
--- a/packages/views/layout/app-rail.tsx
+++ b/packages/views/layout/app-rail.tsx
@@ -26,6 +26,7 @@ import {
type RailSpaceId,
} from "@multica/core/paths";
import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";
+import { TruncatedTooltip } from "@multica/ui/components/common/truncated-tooltip";
import { CappedNumberFlow } from "@multica/ui/components/ui/number-flow";
import { cn } from "@multica/ui/lib/utils";
import { useAppForeground } from "../common/use-app-foreground";
@@ -147,21 +148,33 @@ function RailSpaceLink({
badge?: RailBadge;
}) {
const peekHandlers = usePeekHandlers(space, true);
+ const link = (
+ <AppLink
+ href={href}
+ data-space={space}
+ newTabTitle={fullLabel}
+ draggable={false}
+ aria-current={active ? "page" : undefined}
+ {...peekHandlers}
+ className="group relative flex size-12 flex-col items-center justify-center gap-1 rounded-xl text-muted-foreground transition-colors outline-none hover:bg-sidebar-accent/60 hover:text-sidebar-accent-foreground focus-visible:outline-2 focus-visible:outline-ring aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-sidebar-accent-foreground"
+ >
+ <Icon className="size-5" />
+ <span className="max-w-full truncate px-0.5 text-micro leading-[14px]">{label}</span>
+ {badge && <RailBadgeMark badge={badge} />}
+ </AppLink>
+ );
+ // A label the same as the full name still needs the tooltip whenever a
+ // locale's text doesn't fit the 48px item.
+ if (label === fullLabel) {
+ return (
+ <TruncatedTooltip content={fullLabel} side="right">
+ {link}
+ </TruncatedTooltip>
+ );
+ }
return (
- <TooltipHint label={label === fullLabel ? null : fullLabel} side="right">
- <AppLink
- href={href}
- data-space={space}
- newTabTitle={fullLabel}
- draggable={false}
- aria-current={active ? "page" : undefined}
- {...peekHandlers}
- className="group relative flex size-12 flex-col items-center justify-center gap-1 rounded-xl text-muted-foreground transition-colors outline-none hover:bg-sidebar-accent/60 hover:text-sidebar-accent-foreground focus-visible:outline-2 focus-visible:outline-ring aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-sidebar-accent-foreground"
- >
- <Icon className="size-5" />
- <span className="max-w-full truncate px-0.5 text-micro leading-[14px]">{label}</span>
- {badge && <RailBadgeMark badge={badge} />}
- </AppLink>
+ <TooltipHint label={fullLabel} side="right">
+ {link}
</TooltipHint>
);
}
diff --git a/packages/views/locales/es/layout.json b/packages/views/locales/es/layout.json
index 9a985caf6d..d834304664 100644
--- a/packages/views/locales/es/layout.json
+++ b/packages/views/locales/es/layout.json
@@ -85,7 +85,7 @@
"rail": {
"label": "Navegación de la app",
"sheet_description": "Cambia de sección y de espacio de trabajo.",
- "inbox": "Bandeja de entrada",
+ "inbox": "Bandeja",
"work": "Trabajo",
"team": "Equipo",
"chat": "Chat",