Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(frontend): make dashboard project cards, category tiles and folder crumbs real links (#7671)

claude[bot]0cc5b745b984
diff --git a/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ApplicationSelect.tsx b/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ApplicationSelect.tsx
index 3d1885d074..a90e819b74 100644
--- a/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ApplicationSelect.tsx
+++ b/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ApplicationSelect.tsx
@@ -20,6 +20,23 @@ import {
import { useListPkiApplications } from "@app/hooks/api/pkiApplications";
import { useDebounce } from "@app/hooks/useDebounce";
+// Modified and middle clicks belong to the browser: it opens the row's href in a new tab
+// or window, so we neither preventDefault nor navigate programmatically on those paths.
+const isBrowserHandledClick = (event: React.MouseEvent) =>
+ event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0;
+
+// The row's anchor exists for its href (new-tab, copy link, status bar preview) while cmdk
+// owns activation via onSelect. A plain primary click therefore suppresses the anchor's own
+// navigation and bubbles up to cmdk; a browser-handled click is kept away from cmdk instead,
+// so the current tab stays put while the new one opens.
+const handleRowAnchorClick = (event: React.MouseEvent) => {
+ if (isBrowserHandledClick(event)) {
+ event.stopPropagation();
+ return;
+ }
+ event.preventDefault();
+};
+
const ApplicationSelectInner = ({
applicationName,
projectId,
@@ -30,6 +47,7 @@ const ApplicationSelectInner = ({
orgId: string;
}) => {
const [open, setOpen] = useState(false);
+ const [selectedValue, setSelectedValue] = useState("");
const [search, setSearch] = useState("");
const [debouncedSearch] = useDebounce(search);
const navigate = useNavigate();
@@ -38,6 +56,8 @@ const ApplicationSelectInner = ({
const displayName = applicationName;
+ // cmdk activates a row through onSelect, which fires both on pointer click and on
+ // Enter for the arrow-key selected row, so all plain activation is funnelled here.
const handleSelect = (nextName: string) => {
setOpen(false);
if (nextName === applicationName) return;
@@ -48,7 +68,16 @@ const ApplicationSelectInner = ({
return (
<div className="mr-2 flex min-w-16 items-center gap-1 pr-1 pl-1">
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover
+ open={open}
+ onOpenChange={(nextOpen) => {
+ // Clearing on open lets cmdk pick the first row again, as it did while its
+ // selection was uncontrolled. Reset here rather than on close so the paths that
+ // call setOpen(false) directly cannot leave a stale row selected.
+ if (nextOpen) setSelectedValue("");
+ setOpen(nextOpen);
+ }}
+ >
<PopoverAnchor asChild>
<Link
to={
@@ -69,7 +98,7 @@ const ApplicationSelectInner = ({
</IconButton>
</PopoverTrigger>
<PopoverContent align="start" sideOffset={20} className="w-96 p-0">
- <Command shouldFilter={false}>
+ <Command shouldFilter={false} value={selectedValue} onValueChange={setSelectedValue}>
<CommandInput
aria-label="Search applications"
placeholder="Search applications..."
@@ -84,11 +113,26 @@ const ApplicationSelectInner = ({
key={app.id}
value={app.name}
onSelect={() => handleSelect(app.name)}
- className="gap-2"
+ className="relative gap-2"
>
<Check className={app.name === applicationName ? "opacity-100" : "opacity-0"} />
<div className="flex min-w-0 flex-1 flex-col">
- <span className="truncate text-sm">{app.name}</span>
+ {/* The name is the row's link, so its accessible name comes from visible
+ text and its stretched pseudo-element covers the row. Being a tab stop
+ means focus must drive cmdk's selection: cmdk resolves Enter against the
+ row it has marked aria-selected, never against the focused element, so
+ without this onFocus a tabbed-to row would activate whichever row the
+ arrow keys last selected and switch the user to the wrong application. */}
+ <Link
+ to={
+ `/organizations/${orgId}/projects/cert-manager/${projectId}/applications/${app.name}` as never
+ }
+ className="truncate rounded-sm text-sm outline-0 after:absolute after:inset-0 after:rounded-sm after:content-[''] focus-visible:after:ring-2 focus-visible:after:ring-ring"
+ onFocus={() => setSelectedValue(app.name)}
+ onClick={handleRowAnchorClick}
+ >
+ {app.name}
+ </Link>
<span className="truncate text-[11px] text-muted">
{app.description || "No description"}
</span>
diff --git a/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx b/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx
index d2ffdc6843..b9f9877b95 100644
--- a/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx
+++ b/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx
@@ -35,8 +35,26 @@ import { ProjectType } from "@app/hooks/api/projects/types";
import { useUpdateUserProjectFavorites } from "@app/hooks/api/users/mutation";
import { useGetUserProjectFavorites } from "@app/hooks/api/users/queries";
+// Modified and middle clicks belong to the browser: it opens the row's href in a new tab
+// or window, so we neither preventDefault nor navigate programmatically on those paths.
+const isBrowserHandledClick = (event: React.MouseEvent) =>
+ event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0;
+
+// The row's anchor exists for its href (new-tab, copy link, status bar preview) while cmdk
+// owns activation via onSelect. A plain primary click therefore suppresses the anchor's own
+// navigation and bubbles up to cmdk; a browser-handled click is kept away from cmdk instead,
+// so the current tab stays put while the new one opens.
+const handleRowAnchorClick = (event: React.MouseEvent) => {
+ if (isBrowserHandledClick(event)) {
+ event.stopPropagation();
+ return;
+ }
+ event.preventDefault();
+};
+
const ProjectSelectInner = () => {
const [open, setOpen] = useState(false);
+ const [selectedValue, setSelectedValue] = useState("");
const { currentProject: currentWorkspace } = useProject();
const { currentOrg } = useOrganization();
const { data: projects = [] } = useGetUserProjects();
@@ -81,12 +99,17 @@ const ProjectSelectInner = () => {
return projectOptions;
}, [projects, projectFavorites, currentWorkspace.type]);
+ // cmdk activates a row through onSelect, which fires both on pointer click and on
+ // Enter for the arrow-key selected row, so all plain activation is funnelled here.
const handleSelectProject = (projectId: string) => {
const workspace = projects.find((p) => p.id === projectId);
if (!workspace || workspace.id === currentWorkspace.id) {
setOpen(false);
return;
}
+
+ // Switching projects reloads the page instead of navigating client-side: React Query
+ // throws in the overview when the two projects have a different environment count.
const url = linkOptions({
to: getProjectHomePage(workspace.type, workspace.environments),
params: {
@@ -109,7 +132,16 @@ const ProjectSelectInner = () => {
return (
<div className="mr-2 flex min-w-16 items-center gap-1 pr-1 pl-1">
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover
+ open={open}
+ onOpenChange={(nextOpen) => {
+ // Clearing on open lets cmdk pick the first row again, as it did while its
+ // selection was uncontrolled. Reset here rather than on close so the paths that
+ // call setOpen(false) directly cannot leave a stale row selected.
+ if (nextOpen) setSelectedValue("");
+ setOpen(nextOpen);
+ }}
+ >
<PopoverAnchor className="absolute left-18" />
<Link
to={getProjectHomePage(currentWorkspace.type, currentWorkspace.environments)}
@@ -131,7 +163,7 @@ const ProjectSelectInner = () => {
</IconButton>
</PopoverTrigger>
<PopoverContent align="start" sideOffset={20} className="w-96 p-0">
- <Command>
+ <Command value={selectedValue} onValueChange={setSelectedValue}>
<CommandInput aria-label="Search projects" placeholder="Search projects..." />
<CommandList>
<CommandEmpty>No projects found.</CommandEmpty>
@@ -142,7 +174,7 @@ const ProjectSelectInner = () => {
value={workspace.id}
keywords={[workspace.name]}
onSelect={() => handleSelectProject(workspace.id)}
- className="gap-2"
+ className="relative gap-2"
>
<Check
className={
@@ -150,7 +182,24 @@ const ProjectSelectInner = () => {
}
/>
<div className="flex min-w-0 flex-1 flex-col">
- <span className="truncate text-sm">{workspace.name}</span>
+ {/* The name is the row's link, so its accessible name comes from visible
+ text and its stretched pseudo-element covers the row. Being a tab stop
+ means focus must drive cmdk's selection: cmdk resolves Enter against the
+ row it has marked aria-selected, never against the focused element, so
+ without this onFocus a tabbed-to row would activate whichever row the
+ arrow keys last selected and switch the user to the wrong project. */}
+ <Link
+ to={getProjectHomePage(workspace.type, workspace.environments)}
+ params={{
+ projectId: workspace.id,
+ orgId: workspace.orgId
+ }}
+ className="truncate rounded-sm text-sm outline-0 after:absolute after:inset-0 after:rounded-sm after:content-[''] focus-visible:after:ring-2 focus-visible:after:ring-ring"
+ onFocus={() => setSelectedValue(workspace.id)}
+ onClick={handleRowAnchorClick}
+ >
+ {workspace.name}
+ </Link>
<span className="truncate text-[11px] text-muted">
{workspace.description || "No description"}
</span>
@@ -159,10 +208,10 @@ const ProjectSelectInner = () => {
variant="ghost"
size="xs"
aria-label="toggle favorite"
+ className="relative z-10"
onPointerDown={(e) => e.stopPropagation()}
onClick={async (e) => {
e.stopPropagation();
- e.preventDefault();
await (
workspace.isFavorite ? removeProjectFromFavorites : addProjectToFavorites
)(workspace.id);
diff --git a/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx b/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx
index 5b7fa564c4..0ddb94ced3 100644
--- a/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx
+++ b/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx
@@ -402,13 +402,7 @@ const MyProjectsForType = ({
return (
<Card
key={workspace.id}
- role="button"
- tabIndex={0}
- onClick={() => navigateToProject(workspace)}
- onKeyDown={(e) => {
- if (e.key === "Enter") navigateToProject(workspace);
- }}
- className={`group h-full cursor-pointer bg-container transition-all duration-200 ease-out ${tileStyle.cardHoverClassName}`}
+ className={`group relative h-full cursor-pointer bg-container transition-all duration-200 ease-out ${tileStyle.cardHoverClassName}`}
>
<CardHeader>
<div className="flex min-w-0 items-start gap-3">
@@ -416,15 +410,24 @@ const MyProjectsForType = ({
<WorkspaceIcon className="size-5.5 shrink-0 text-accent transition-colors duration-200 ease-out group-hover:text-project" />
</div>
<div className="min-w-0 flex-1">
- <CardDescription className="truncate text-base font-semibold text-foreground">
- {workspace.name}
+ <CardDescription className="text-base font-semibold text-foreground">
+ {/* The name is the card's link, so the accessible name comes from visible text
+ rather than a duplicated label, and its stretched pseudo-element covers the
+ card. Siblings raised above it (CardAction) stay outside the anchor. */}
+ <Link
+ to={getProjectHomePage(workspace.type, workspace.environments)}
+ params={{ orgId: currentOrg?.id || "", projectId: workspace.id }}
+ className="block truncate outline-0 after:absolute after:inset-0 after:rounded-lg after:content-[''] focus-visible:after:ring-2 focus-visible:after:ring-ring"
+ >
+ {workspace.name}
+ </Link>
</CardDescription>
<p className="truncate text-sm leading-5 text-muted">
{getProjectTitle(workspace.type)}
</p>
</div>
</div>
- <CardAction>{renderFavoriteButton(workspace)}</CardAction>
+ <CardAction className="relative z-10">{renderFavoriteButton(workspace)}</CardAction>
</CardHeader>
<CardContent className="flex flex-col gap-3">
<p className="line-clamp-2 text-sm leading-relaxed text-accent">
diff --git a/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx b/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx
index 5bae95ad69..5c64c9e283 100644
--- a/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx
+++ b/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx
@@ -1,5 +1,5 @@
import { useMemo, useState } from "react";
-import { useNavigate } from "@tanstack/react-router";
+import { Link, useNavigate } from "@tanstack/react-router";
import { createNotification } from "@app/components/notifications";
import { CertManagerNotConfiguredModal } from "@app/components/projects/CertManagerNotConfiguredModal";
@@ -441,19 +441,36 @@ export const ProjectCategoryOverview = () => {
);
}
+ const tileClassName = `group h-auto cursor-pointer rounded-md transition-all duration-200 ease-out hover:scale-[1.01] ${cardClassName}`;
+
+ // Cert Manager and PAM resolve their destination asynchronously (instance picker,
+ // lazy project bootstrap, join-on-behalf), so they stay handler-driven.
+ if (type === ProjectType.CertificateManager || type === ProjectType.PAM) {
+ return (
+ <Card
+ key={type}
+ role="button"
+ tabIndex={0}
+ onClick={() => handleTileClick(type)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") handleTileClick(type);
+ }}
+ className={tileClassName}
+ >
+ {tileBody}
+ </Card>
+ );
+ }
+
return (
- <Card
+ <Link
key={type}
- role="button"
- tabIndex={0}
- onClick={() => handleTileClick(type)}
- onKeyDown={(e) => {
- if (e.key === "Enter") handleTileClick(type);
- }}
- className={`group h-auto cursor-pointer rounded-md transition-all duration-200 ease-out hover:scale-[1.01] ${cardClassName}`}
+ to="/organizations/$orgId/projects/$type"
+ params={{ orgId: currentOrg?.id || "", type: projectTypeToUrlSlug(type) }}
+ className="block"
>
- {tileBody}
- </Card>
+ <Card className={tileClassName}>{tileBody}</Card>
+ </Link>
);
})}
</div>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/FolderBreadcrumb/FolderBreadcrumb.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/FolderBreadcrumb/FolderBreadcrumb.tsx
index 7952de28de..20ba1006b5 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/FolderBreadcrumb/FolderBreadcrumb.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/FolderBreadcrumb/FolderBreadcrumb.tsx
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
-import { useNavigate } from "@tanstack/react-router";
+import { Link } from "@tanstack/react-router";
import { Check, Copy, FolderIcon, SlashIcon } from "lucide-react";
import {
@@ -35,10 +35,6 @@ type Measurements = {
};
export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
- const navigate = useNavigate({
- from: "/organizations/$orgId/projects/secret-management/$projectId/overview"
- });
-
const containerRef = useRef<HTMLDivElement>(null);
const measureContainerRef = useRef<HTMLDivElement>(null);
@@ -54,15 +50,24 @@ export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
const [isCopied, , setIsCopied] = useTimedReset<boolean>({ initialState: false });
+ const getCrumbPath = useCallback(
+ (index: number) => `/${secretPath.split("/").filter(Boolean).slice(0, index).join("/")}`,
+ [secretPath]
+ );
+
+ // The crumb is a real link, so the browser owns the navigation; this only restores the
+ // filters previously used at that depth, and must not run when the click is a new-tab
+ // gesture that leaves this tab where it is.
const onFolderCrumbClick = useCallback(
- (index: number) => {
- const newSecPath = `/${secretPath.split("/").filter(Boolean).slice(0, index).join("/")}`;
+ (event: React.MouseEvent, index: number) => {
+ if (event.defaultPrevented) return;
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0)
+ return;
+ const newSecPath = getCrumbPath(index);
if (secretPath === newSecPath) return;
- navigate({
- search: (prev) => ({ ...prev, secretPath: newSecPath })
- }).then(() => onResetSearch(newSecPath));
+ onResetSearch(newSecPath);
},
- [secretPath, navigate, onResetSearch]
+ [getCrumbPath, secretPath, onResetSearch]
);
// Measure all elements and track container width
@@ -253,9 +258,17 @@ export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
<Breadcrumb className="min-w-0 overflow-hidden">
<BreadcrumbList className="flex-nowrap">
{/* Root folder icon */}
- <BreadcrumbItem onClick={() => onFolderCrumbClick(0)}>
- <BreadcrumbLink>
- <FolderIcon />
+ <BreadcrumbItem>
+ <BreadcrumbLink asChild>
+ <Link
+ from="/organizations/$orgId/projects/secret-management/$projectId/overview"
+ to="."
+ search={(prev) => ({ ...prev, secretPath: getCrumbPath(0) })}
+ onClick={(event) => onFolderCrumbClick(event, 0)}
+ aria-label="Root folder"
+ >
+ <FolderIcon />
+ </Link>
</BreadcrumbLink>
</BreadcrumbItem>
@@ -270,12 +283,16 @@ export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
{path}
</BreadcrumbPage>
) : (
- <BreadcrumbItem
- onClick={() => onFolderCrumbClick(index + 1)}
- onKeyDown={() => null}
- >
- <BreadcrumbLink title={path} className="truncate">
- {path}
+ <BreadcrumbItem>
+ <BreadcrumbLink asChild title={path} className="truncate">
+ <Link
+ from="/organizations/$orgId/projects/secret-management/$projectId/overview"
+ to="."
+ search={(prev) => ({ ...prev, secretPath: getCrumbPath(index + 1) })}
+ onClick={(event) => onFolderCrumbClick(event, index + 1)}
+ >
+ {path}
+ </Link>
</BreadcrumbLink>
</BreadcrumbItem>
)}
@@ -301,15 +318,25 @@ export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
const originalIndex = startCount + idx;
return (
<DropdownMenuItem
+ asChild
key={`hidden-${originalIndex}`}
- onClick={() => onFolderCrumbClick(originalIndex + 1)}
className="text-accent hover:text-foreground"
title={segment}
>
- <div className="absolute top-1/2 -left-[3px] h-px w-2 bg-muted/50 transition-colors" />
-
- <FolderIcon className="text-folder" />
- <span className="truncate">{segment}</span>
+ <Link
+ from="/organizations/$orgId/projects/secret-management/$projectId/overview"
+ to="."
+ search={(prev) => ({
+ ...prev,
+ secretPath: getCrumbPath(originalIndex + 1)
+ })}
+ onClick={(event) => onFolderCrumbClick(event, originalIndex + 1)}
+ >
+ <div className="absolute top-1/2 -left-[3px] h-px w-2 bg-muted/50 transition-colors" />
+
+ <FolderIcon className="text-folder" />
+ <span className="truncate">{segment}</span>
+ </Link>
</DropdownMenuItem>
);
})}
@@ -333,12 +360,19 @@ export function FolderBreadcrumb({ secretPath = "", onResetSearch }: Props) {
{path}
</BreadcrumbPage>
) : (
- <BreadcrumbItem
- onClick={() => onFolderCrumbClick(originalIndex + 1)}
- onKeyDown={() => null}
- >
- <BreadcrumbLink title={path} className="truncate">
- {path}
+ <BreadcrumbItem>
+ <BreadcrumbLink asChild title={path} className="truncate">
+ <Link
+ from="/organizations/$orgId/projects/secret-management/$projectId/overview"
+ to="."
+ search={(prev) => ({
+ ...prev,
+ secretPath: getCrumbPath(originalIndex + 1)
+ })}
+ onClick={(event) => onFolderCrumbClick(event, originalIndex + 1)}
+ >
+ {path}
+ </Link>
</BreadcrumbLink>
</BreadcrumbItem>
)}