Skip to content

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

improvement: use divs instead of dialog to avoid focus/keyboard nav issues for access denied dialog

Scott Wilson4cdf374054c9
diff --git a/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.tsx b/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.tsx
index f9ca72ed08..3d247f588a 100644
--- a/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.tsx
+++ b/frontend/src/components/v3/platform/AccessRestricted/AccessRestrictedDialog.tsx
@@ -1,17 +1,9 @@
-import { ReactNode } from "react";
+import { ReactNode, useId } from "react";
import { Link } from "@tanstack/react-router";
import { ArrowLeftIcon, ExternalLinkIcon, HouseIcon, InfoIcon, LockIcon } from "lucide-react";
import { Badge } from "../../generic/Badge";
import { Button } from "../../generic/Button";
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogTitle
-} from "../../generic/Dialog";
import { cn } from "../../utils";
const RBAC_DOCS_URL =
@@ -21,7 +13,7 @@ const RBAC_DOCS_URL =
// rather than implying a specific number or shape of records the viewer is missing.
const REDACTED_ROW_WIDTHS = ["w-48", "w-64", "w-40", "w-56", "w-44", "w-60", "w-52", "w-36"];
-// The gated page can't be rendered behind the dialog — its queries would 403, and the suspense
+// The gated page can't be rendered behind the panel — its queries would 403, and the suspense
// ones would escalate into the router error boundary — so the region keeps page-shaped volume
// with inert bars instead.
const RedactedBackdrop = () => (
@@ -77,10 +69,10 @@ type Props = {
};
/**
- * Page- and tab-level permission gate, styled to the ErrorPage/ForbiddenPage family. Leaves the
- * surrounding page chrome visible and interactive (the dialog is deliberately non-modal, so the
- * sidebar and sibling tabs still work) and floats the explanation over a redacted stand-in for
- * the content.
+ * Page- and tab-level permission gate, styled to the ErrorPage/ForbiddenPage family: a
+ * dialog-look panel floating over a redacted stand-in for the content. It renders in normal
+ * document flow, so the surrounding page chrome (sidebar, sibling tabs) stays usable by both
+ * pointer and keyboard.
*
* For a single section inside an otherwise usable page, use AccessRestrictedNotice instead.
*/
@@ -93,6 +85,8 @@ export const AccessRestrictedDialog = ({
action,
className
}: Props) => {
+ const titleId = useId();
+
const monoRows: [string, string][] = [
...(requirement
? ([["requires", `${requirement.action} on ${requirement.subject}`]] as [string, string][])
@@ -100,24 +94,34 @@ export const AccessRestrictedDialog = ({
["route", window.location.pathname]
];
+ // Deliberately NOT a real <Dialog>: this is a permanent page state with no close affordance,
+ // and Radix DialogContent hardcodes a Tab loop (FocusScope loop) plus mount autofocus even
+ // when non-modal, so keyboard focus would be pulled in and could never reach the page chrome
+ // again. The grid stacks panel over backdrop so the gate is as tall as the larger of the two.
return (
- <div className={cn("relative w-full py-2", className)}>
- <RedactedBackdrop />
- {/* Held open with no onOpenChange: this is a page state, not a dismissible dialog. */}
- <Dialog open modal={false}>
- <DialogContent showCloseButton={false} className="max-w-2xl gap-5">
- <DialogHeader className="items-start gap-5">
+ <div className={cn("grid w-full py-2", className)}>
+ <div className="col-start-1 row-start-1">
+ <RedactedBackdrop />
+ </div>
+ {/* relative: the backdrop's blur filter forms a stacking context that would otherwise
+ paint over this statically-positioned cell. */}
+ <div className="relative col-start-1 row-start-1 flex items-center justify-center p-4">
+ <section
+ aria-labelledby={titleId}
+ className="flex w-full max-w-2xl animate-in flex-col gap-5 rounded-lg border border-border bg-popover p-6 pb-0 text-foreground shadow-lg duration-200 fade-in-0 zoom-in-95"
+ >
+ <div className="flex flex-col items-start gap-5 text-left">
<Badge variant="warning" className="h-6 px-2">
<LockIcon />
Access Restricted
</Badge>
- <DialogTitle className="text-3xl leading-tight font-semibold">
+ <h2 id={titleId} className="text-3xl leading-tight font-semibold">
{title}
<br />
<span className="text-2xl">{subtitle}</span>
- </DialogTitle>
- <DialogDescription className="leading-relaxed">{description}</DialogDescription>
- </DialogHeader>
+ </h2>
+ <p className="text-sm leading-relaxed text-accent">{description}</p>
+ </div>
<div className="flex flex-col gap-1.5 rounded-md border border-border bg-bunker-800/50 px-4 py-3">
{monoRows.map(([key, value]) => (
<div key={key} className="flex gap-4 font-mono text-xs">
@@ -136,7 +140,7 @@ export const AccessRestrictedDialog = ({
Access control documentation
<ExternalLinkIcon className="size-3" />
</a>
- <DialogFooter>
+ <div className="-mx-6 flex flex-row flex-wrap justify-end gap-2 rounded-b-lg border-t border-border bg-container p-4">
<Button variant="outline" onClick={() => window.history.back()}>
<ArrowLeftIcon />
Go Back
@@ -148,9 +152,9 @@ export const AccessRestrictedDialog = ({
</Link>
</Button>
{action}
- </DialogFooter>
- </DialogContent>
- </Dialog>
+ </div>
+ </section>
+ </div>
</div>
);
};