Skip to content

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

Go

fix(lists): navigate rows via onClick, not a nested row anchor (#4146)

Naiyuan Qing3ce4cf6f2f77
diff --git a/packages/ui/components/ui/list-grid.tsx b/packages/ui/components/ui/list-grid.tsx
index 3d194273aa..46a9acf77d 100644
--- a/packages/ui/components/ui/list-grid.tsx
+++ b/packages/ui/components/ui/list-grid.tsx
@@ -1,6 +1,5 @@
"use client";
-import { cloneElement } from "react";
import { ArrowDown, ArrowUp } from "lucide-react";
import { cn } from "../../lib/utils";
@@ -161,39 +160,29 @@ function ListGridBody({
// extra runway keeps both off the final row's kebab.
export const LIST_GRID_BOTTOM_CLEARANCE = 64;
-interface ListGridRowProps extends React.HTMLAttributes<HTMLElement> {
- /**
- * Base UI-style render prop: pass an element (e.g. `<AppLink href={...} />`)
- * to use it as the row root; the row classes and cells are merged onto it.
- */
- render?: React.ReactElement<{
- className?: string;
- children?: React.ReactNode;
- }>;
-}
+// A row is a plain `<div>`, never an `<a>` — so interactive cells (checkbox,
+// kebab, inline editors) are valid siblings, not interactive content nested
+// inside an anchor (which is invalid HTML and made native navigation fire on
+// every child click). Whole-row navigation is a MOUSE convenience layered on
+// via `onClick`/`onAuxClick` (see views `useRowLink`); the keyboard- and
+// screen-reader-accessible link, plus right-click "open in new tab", live on
+// the real `<AppLink>` inside the name cell. Interactive cells call
+// `stopPropagation` so clicking them never triggers the row's navigation.
+type ListGridRowProps = React.HTMLAttributes<HTMLDivElement>;
-function ListGridRow({ render, className, children, ...props }: ListGridRowProps) {
- const rowClassName = cn(
- "group/row col-span-full grid h-12 grid-cols-subgrid items-center transition-colors hover:bg-accent/40",
- className,
- );
- const content = (
- <>
+function ListGridRow({ className, children, ...props }: ListGridRowProps) {
+ return (
+ <div
+ role="row"
+ className={cn(
+ "group/row col-span-full grid h-12 grid-cols-subgrid items-center transition-colors hover:bg-accent/40",
+ className,
+ )}
+ {...props}
+ >
<span aria-hidden="true" />
{children}
<span aria-hidden="true" />
- </>
- );
- if (render) {
- return cloneElement(
- render,
- { ...props, className: cn(rowClassName, render.props.className) },
- content,
- );
- }
- return (
- <div className={rowClassName} {...props}>
- {content}
</div>
);
}
diff --git a/packages/views/agents/components/agent-detail-page.tsx b/packages/views/agents/components/agent-detail-page.tsx
index 96e656ed48..86b2524226 100644
--- a/packages/views/agents/components/agent-detail-page.tsx
+++ b/packages/views/agents/components/agent-detail-page.tsx
@@ -401,7 +401,7 @@ function DetailHeader({
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-auto">
<DropdownMenuItem
- className="text-destructive"
+ variant="destructive"
onClick={onArchive}
>
<Trash2 className="h-3.5 w-3.5" />
diff --git a/packages/views/agents/components/agent-row-actions.tsx b/packages/views/agents/components/agent-row-actions.tsx
index 9ff1a78a6b..c25e209fbf 100644
--- a/packages/views/agents/components/agent-row-actions.tsx
+++ b/packages/views/agents/components/agent-row-actions.tsx
@@ -26,7 +26,6 @@ import {
AlertDialogHeader,
AlertDialogTitle,
} from "@multica/ui/components/ui/alert-dialog";
-import { Button } from "@multica/ui/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
@@ -54,10 +53,12 @@ interface AgentRowActionsProps {
* from (a) the agent's lifecycle state (active vs archived) and (b) the
* caller's permission level. If no actions apply, the trigger is omitted so
* the row renders an empty cell (column width still preserved by the parent
- * `<TableCell className="w-10" />`).
+ * ListGridCell).
*
- * All triggers stop event propagation so clicks don't bubble up to the
- * row's navigate-to-detail handler.
+ * The row is a plain `<div>` whose whole-row navigation is a mouse `onClick`
+ * (see `useRowLink`), not an ancestor `<a>`. The host cell stops click
+ * propagation so opening this menu never navigates the row; the trigger
+ * itself needs no guard. Menu and dialog content is portaled out of the row.
*/
export function AgentRowActions({
agent,
@@ -134,24 +135,16 @@ export function AgentRowActions({
<DropdownMenu>
<DropdownMenuTrigger
render={
- <Button
- variant="ghost"
- size="icon-sm"
+ <button
+ type="button"
aria-label={t(($) => $.row.actions_aria)}
- onClick={(e) => e.stopPropagation()}
- onKeyDown={(e) => e.stopPropagation()}
- />
+ className="flex size-7 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-accent-foreground group-hover/row:opacity-100 data-popup-open:bg-accent data-popup-open:opacity-100 data-popup-open:text-accent-foreground"
+ >
+ <MoreHorizontal className="size-4" />
+ </button>
}
- >
- <MoreHorizontal className="h-4 w-4 text-muted-foreground" />
- </DropdownMenuTrigger>
- <DropdownMenuContent
- align="end"
- className="w-auto"
- // Prevent the row's onClick from firing if a click on a menu item
- // somehow bubbles back through the portal.
- onClick={(e) => e.stopPropagation()}
- >
+ />
+ <DropdownMenuContent align="end" className="w-auto">
{showStop && (
<DropdownMenuItem
onClick={() => setConfirmCancel(true)}
@@ -176,7 +169,7 @@ export function AgentRowActions({
<>
<DropdownMenuSeparator />
<DropdownMenuItem
- className="text-destructive"
+ variant="destructive"
onClick={() => setConfirmArchive(true)}
>
<Trash2 className="h-3.5 w-3.5" />
@@ -194,10 +187,7 @@ export function AgentRowActions({
if (!v) setConfirmCancel(false);
}}
>
- <AlertDialogContent
- // Keep clicks inside the dialog from bubbling to the row.
- onClick={(e) => e.stopPropagation()}
- >
+ <AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
{t(($) => $.row_actions.cancel_dialog_title, { name: agent.name })}
@@ -231,7 +221,7 @@ export function AgentRowActions({
if (!v) setConfirmArchive(false);
}}
>
- <AlertDialogContent onClick={(e) => e.stopPropagation()}>
+ <AlertDialogContent>
<AlertDialogHeader>
<div className="flex items-start gap-3">
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-destructive/10">
diff --git a/packages/views/agents/components/agents-page.tsx b/packages/views/agents/components/agents-page.tsx
index f54a6f194d..6cc2543d06 100644
--- a/packages/views/agents/components/agents-page.tsx
+++ b/packages/views/agents/components/agents-page.tsx
@@ -72,7 +72,7 @@ import {
TooltipContent,
TooltipTrigger,
} from "@multica/ui/components/ui/tooltip";
-import { AppLink, useNavigation } from "../../navigation";
+import { useNavigation, useRowLink } from "../../navigation";
import { ActorAvatar } from "../../common/actor-avatar";
import { PageHeader } from "../../layout/page-header";
import { availabilityConfig } from "../presence";
@@ -295,7 +295,6 @@ function CheckboxCell({
type="button"
aria-pressed={checked}
onClick={(e) => {
- e.preventDefault();
e.stopPropagation();
onToggle();
}}
@@ -795,6 +794,7 @@ export function AgentsPage(_props: AgentsPageProps = {}) {
const wsId = useWorkspaceId();
const paths = useWorkspacePaths();
const navigation = useNavigation();
+ const rowLink = useRowLink();
const qc = useQueryClient();
const currentUser = useAuthStore((s) => s.user);
@@ -1124,12 +1124,10 @@ export function AgentsPage(_props: AgentsPageProps = {}) {
return (
<ListGridRow
key={row.agent.id}
- className={`h-16 ${
+ className={`h-16 cursor-pointer ${
selectedIds.has(row.agent.id) ? "bg-accent/30" : ""
}`}
- render={
- <AppLink href={paths.agentDetail(row.agent.id)} />
- }
+ {...rowLink(paths.agentDetail(row.agent.id))}
>
<CheckboxCell
checked={selectedIds.has(row.agent.id)}
@@ -1183,11 +1181,8 @@ export function AgentsPage(_props: AgentsPageProps = {}) {
)}
<ListGridCell className="justify-end px-0">
<span
- onClick={(e) => {
- e.preventDefault();
- e.stopPropagation();
- }}
- className="flex items-center opacity-0 transition-opacity group-hover/row:opacity-100"
+ onClick={(e) => e.stopPropagation()}
+ className="flex items-center"
>
<AgentRowActions
agent={row.agent}
diff --git a/packages/views/autopilots/components/autopilot-list-actions.tsx b/packages/views/autopilots/components/autopilot-list-actions.tsx
index 60a7b80fad..b28c7060ac 100644
--- a/packages/views/autopilots/components/autopilot-list-actions.tsx
+++ b/packages/views/autopilots/components/autopilot-list-actions.tsx
@@ -135,9 +135,10 @@ function useSetStatus() {
}
// ---------------------------------------------------------------------------
-// Row kebab — lives inside the row <a>; the wrapper span intercepts clicks
-// so opening the menu neither navigates nor triggers AppLink's push (same
-// pattern as the skills list).
+// Row kebab — the row is a plain `<div>` whose whole-row navigation is a mouse
+// `onClick` (see `useRowLink`), not an ancestor `<a>`. The wrapper span stops
+// click propagation so opening this menu never navigates the row — just
+// stopPropagation, no preventDefault (same pattern as the skills list).
// ---------------------------------------------------------------------------
export function AutopilotRowActions({ row }: { row: Autopilot }) {
@@ -147,10 +148,7 @@ export function AutopilotRowActions({ row }: { row: Autopilot }) {
return (
<span
- onClick={(e) => {
- e.preventDefault();
- e.stopPropagation();
- }}
+ onClick={(e) => e.stopPropagation()}
className="flex items-center"
>
<DropdownMenu>
diff --git a/packages/views/autopilots/components/autopilots-page.tsx b/packages/views/autopilots/components/autopilots-page.tsx
index 0fd88abe58..3ff3f789f3 100644
--- a/packages/views/autopilots/components/autopilots-page.tsx
+++ b/packages/views/autopilots/components/autopilots-page.tsx
@@ -44,7 +44,7 @@ import {
type ListGridSortDirection,
} from "@multica/ui/components/ui/list-grid";
import { Skeleton } from "@multica/ui/components/ui/skeleton";
-import { AppLink } from "../../navigation";
+import { useRowLink } from "../../navigation";
import { ActorAvatar } from "../../common/actor-avatar";
import { PageHeader } from "../../layout/page-header";
import { AutopilotDialog } from "./autopilot-dialog";
@@ -222,7 +222,6 @@ function CheckboxCell({
type="button"
aria-pressed={checked}
onClick={(e) => {
- e.preventDefault();
e.stopPropagation();
onToggle();
}}
@@ -602,6 +601,7 @@ export function AutopilotsPage() {
const { t } = useT("autopilots");
const wsId = useWorkspaceId();
const wsPaths = useWorkspacePaths();
+ const rowLink = useRowLink();
const {
data: autopilots = [],
isLoading,
@@ -903,14 +903,10 @@ export function AutopilotsPage() {
return (
<ListGridRow
key={autopilot.id}
- className={
- selectedIds.has(autopilot.id)
- ? "bg-accent/30"
- : undefined
- }
- render={
- <AppLink href={wsPaths.autopilotDetail(autopilot.id)} />
- }
+ className={`cursor-pointer ${
+ selectedIds.has(autopilot.id) ? "bg-accent/30" : ""
+ }`}
+ {...rowLink(wsPaths.autopilotDetail(autopilot.id))}
>
<CheckboxCell
checked={selectedIds.has(autopilot.id)}
diff --git a/packages/views/navigation/index.ts b/packages/views/navigation/index.ts
index 069b0f7114..52dc3d4a28 100644
--- a/packages/views/navigation/index.ts
+++ b/packages/views/navigation/index.ts
@@ -4,4 +4,5 @@ export {
useIsNavigating,
} from "./context";
export { AppLink } from "./app-link";
+export { useRowLink } from "./use-row-link";
export type { NavigationAdapter } from "./types";
diff --git a/packages/views/navigation/use-row-link.ts b/packages/views/navigation/use-row-link.ts
new file mode 100644
index 0000000000..65ba2b86fe
--- /dev/null
+++ b/packages/views/navigation/use-row-link.ts
@@ -0,0 +1,52 @@
+"use client";
+
+import { useCallback } from "react";
+import { useNavigation } from "./context";
+
+/**
+ * Whole-row click navigation for list rows.
+ *
+ * Call once at the top of a list component; it returns a factory that builds
+ * the props to spread onto each `<ListGridRow>` (a plain `<div>`, never an
+ * `<a>`) given that row's href. Calling it per row keeps it outside the
+ * rules-of-hooks trap of invoking `useNavigation` inside a `.map()`.
+ *
+ * The whole row navigates on click — the row is the click target, so the
+ * name cell stays plain text (no nested `<a>`, which would be a redundant
+ * second entry point). Interactive cells (checkbox, kebab, inline editors)
+ * call `stopPropagation` so clicking them never reaches these handlers.
+ *
+ * Mirrors AppLink's modifier semantics: a plain left click pushes; cmd/ctrl
+ * (or a middle click) opens a background tab on desktop.
+ *
+ * Callers add `cursor-pointer` to the row's own className (kept out of the
+ * returned props so it can't clash with the row's existing className).
+ */
+export function useRowLink() {
+ const { push, openInNewTab, prefetch } = useNavigation();
+
+ return useCallback(
+ (href: string) => {
+ const open = (newTab: boolean) => {
+ if (newTab && openInNewTab) openInNewTab(href);
+ else push(href);
+ };
+ return {
+ onClick: (e: React.MouseEvent) => {
+ // A child control already handled this click (controls call
+ // stopPropagation and never reach here; defaultPrevented guards
+ // any that preventDefault instead).
+ if (e.defaultPrevented || e.button !== 0) return;
+ open(e.metaKey || e.ctrlKey);
+ },
+ onAuxClick: (e: React.MouseEvent) => {
+ if (e.defaultPrevented || e.button !== 1) return; // middle click
+ e.preventDefault();
+ open(true);
+ },
+ onMouseEnter: () => prefetch?.(href),
+ };
+ },
+ [push, openInNewTab, prefetch],
+ );
+}
diff --git a/packages/views/runtimes/components/runtime-list.tsx b/packages/views/runtimes/components/runtime-list.tsx
index bcf8940cfc..50045254b4 100644
--- a/packages/views/runtimes/components/runtime-list.tsx
+++ b/packages/views/runtimes/components/runtime-list.tsx
@@ -22,7 +22,6 @@ import {
runtimeUsageOptions,
} from "@multica/core/runtimes";
import { useWorkspacePaths } from "@multica/core/paths";
-import { Button } from "@multica/ui/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
@@ -41,7 +40,7 @@ import {
TooltipContent,
TooltipTrigger,
} from "@multica/ui/components/ui/tooltip";
-import { AppLink } from "../../navigation";
+import { useRowLink } from "../../navigation";
import { ActorAvatar } from "../../common/actor-avatar";
import { useViewingTimezone } from "../../common/use-viewing-timezone";
import { ProviderLogo } from "./provider-logo";
@@ -393,22 +392,16 @@ export function RuntimeRowMenu({
<DropdownMenu>
<DropdownMenuTrigger
render={
- <Button
- variant="ghost"
- size="icon-sm"
+ <button
+ type="button"
aria-label={t(($) => $.list.row_actions_aria)}
- onClick={(e) => e.stopPropagation()}
- onKeyDown={(e) => e.stopPropagation()}
- />
+ className="flex size-7 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-accent-foreground group-hover/row:opacity-100 data-popup-open:bg-accent data-popup-open:opacity-100 data-popup-open:text-accent-foreground"
+ >
+ <MoreHorizontal className="size-4" />
+ </button>
}
- >
- <MoreHorizontal className="h-4 w-4 text-muted-foreground" />
- </DropdownMenuTrigger>
- <DropdownMenuContent
- align="end"
- className="w-40"
- onClick={(e) => e.stopPropagation()}
- >
+ />
+ <DropdownMenuContent align="end" className="w-40">
<DropdownMenuItem
variant="destructive"
onClick={() => setDeleteOpen(true)}
@@ -456,6 +449,7 @@ export function RuntimeList({
const { t } = useT("runtimes");
const wsId = useWorkspaceId();
const wsPaths = useWorkspacePaths();
+ const rowLink = useRowLink();
const user = useAuthStore((s) => s.user);
const { data: agents = [] } = useQuery(agentListOptions(wsId));
@@ -540,7 +534,8 @@ export function RuntimeList({
{rows.map((row) => (
<ListGridRow
key={row.runtime.id}
- render={<AppLink href={wsPaths.runtimeDetail(row.runtime.id)} />}
+ className="cursor-pointer"
+ {...rowLink(wsPaths.runtimeDetail(row.runtime.id))}
>
<RuntimeNameCell runtime={row.runtime} />
<HealthCell
@@ -579,10 +574,7 @@ export function RuntimeList({
</ListGridCell>
<ListGridCell className="justify-end px-0">
<span
- onClick={(e) => {
- e.preventDefault();
- e.stopPropagation();
- }}
+ onClick={(e) => e.stopPropagation()}
className="flex items-center"
>
<RuntimeRowMenu
diff --git a/packages/views/skills/components/skill-list-actions.tsx b/packages/views/skills/components/skill-list-actions.tsx
index a5b7a97d0b..1d54988ea5 100644
--- a/packages/views/skills/components/skill-list-actions.tsx
+++ b/packages/views/skills/components/skill-list-actions.tsx
@@ -471,11 +471,10 @@ export function DeleteSkillsDialog({
// Row kebab
// ---------------------------------------------------------------------------
-// Lives inside the row <a>; the wrapper span intercepts clicks so opening
-// the menu neither navigates (preventDefault kills the anchor's native
-// navigation) nor triggers AppLink's push (stopPropagation). Dialog and menu
-// contents are portaled, but their React events still bubble through this
-// span — which is exactly what keeps them from reaching the row link.
+// The row is a plain `<div>` whose whole-row navigation is a mouse `onClick`
+// (see `useRowLink`), not an ancestor `<a>`. The wrapper span stops click
+// propagation so opening this menu never navigates the row — just
+// stopPropagation, no preventDefault (there is no native anchor to cancel).
export function SkillRowActions({
row,
ctx,
@@ -489,10 +488,7 @@ export function SkillRowActions({
return (
<span
- onClick={(e) => {
- e.preventDefault();
- e.stopPropagation();
- }}
+ onClick={(e) => e.stopPropagation()}
className="flex items-center"
>
<DropdownMenu>
diff --git a/packages/views/skills/components/skills-page.tsx b/packages/views/skills/components/skills-page.tsx
index 21b0ea396f..a7fa8fdd54 100644
--- a/packages/views/skills/components/skills-page.tsx
+++ b/packages/views/skills/components/skills-page.tsx
@@ -50,7 +50,7 @@ import {
TooltipTrigger,
} from "@multica/ui/components/ui/tooltip";
import { ActorAvatar } from "@multica/ui/components/common/actor-avatar";
-import { AppLink, useNavigation } from "../../navigation";
+import { useNavigation, useRowLink } from "../../navigation";
import { PageHeader } from "../../layout/page-header";
import { canEditSkill } from "../hooks/use-can-edit-skill";
import { readOrigin, type OriginInfo } from "../lib/origin";
@@ -213,9 +213,9 @@ function PageHeaderBar({
// Hover-revealed multi-select checkbox. Same pattern as SkillPickerList:
// the shadcn Checkbox is presentational only (`pointer-events-none`, so the
// Base UI button can never swallow the click) and the wrapping <button> owns
-// the interaction — preventDefault kills the row link's native navigation
-// (the cell lives inside an <a>), stopPropagation keeps AppLink's push from
-// firing, and the manual toggle drives the state.
+// the toggle. It stops click propagation so toggling never triggers the
+// row's whole-row navigation (see `useRowLink`) — no preventDefault needed,
+// the row is a plain <div>, not an <a>.
function CheckboxCell({
checked,
onToggle,
@@ -229,7 +229,6 @@ function CheckboxCell({
type="button"
aria-pressed={checked}
onClick={(e) => {
- e.preventDefault();
e.stopPropagation();
onToggle();
}}
@@ -578,6 +577,7 @@ export default function SkillsPage() {
const wsId = useWorkspaceId();
const paths = useWorkspacePaths();
const navigation = useNavigation();
+ const rowLink = useRowLink();
const timeAgo = useTimeAgo();
const currentUserId = useAuthStore((s) => s.user?.id ?? null);
@@ -885,10 +885,10 @@ export default function SkillsPage() {
return (
<ListGridRow
key={row.skill.id}
- className={
- selectedIds.has(row.skill.id) ? "bg-accent/30" : undefined
- }
- render={<AppLink href={paths.skillDetail(row.skill.id)} />}
+ className={`cursor-pointer ${
+ selectedIds.has(row.skill.id) ? "bg-accent/30" : ""
+ }`}
+ {...rowLink(paths.skillDetail(row.skill.id))}
>
<CheckboxCell
checked={selectedIds.has(row.skill.id)}
diff --git a/packages/views/squads/components/squads-page.tsx b/packages/views/squads/components/squads-page.tsx
index aa550dd92e..d02f199aed 100644
--- a/packages/views/squads/components/squads-page.tsx
+++ b/packages/views/squads/components/squads-page.tsx
@@ -81,7 +81,7 @@ import {
import { ActorAvatar as ActorAvatarBase } from "@multica/ui/components/common/actor-avatar";
import { ActorAvatar } from "../../common/actor-avatar";
import { FILTER_ITEM_CLASS, HoverCheck } from "../../common/hover-check";
-import { AppLink } from "../../navigation";
+import { useRowLink } from "../../navigation";
import { PageHeader } from "../../layout/page-header";
import { useT } from "../../i18n";
@@ -314,10 +314,7 @@ function SquadRowActions({ squad }: { squad: Squad }) {
const [archiveOpen, setArchiveOpen] = useState(false);
return (
<span
- onClick={(e) => {
- e.preventDefault();
- e.stopPropagation();
- }}
+ onClick={(e) => e.stopPropagation()}
className="flex items-center"
>
<DropdownMenu>
@@ -754,6 +751,7 @@ export function SquadsPage() {
const workspace = useCurrentWorkspace();
const wsId = workspace?.id ?? "";
const p = useWorkspacePaths();
+ const rowLink = useRowLink();
const currentUser = useAuthStore((s) => s.user);
const { data: squads = [], isLoading } = useQuery({
@@ -960,7 +958,8 @@ export function SquadsPage() {
rows.map((squad) => (
<ListGridRow
key={squad.id}
- render={<AppLink href={p.squadDetail(squad.id)} />}
+ className="cursor-pointer"
+ {...rowLink(p.squadDetail(squad.id))}
>
<NameCell squad={squad} />
<LeaderCell