Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(ui): contain alert dialog confirmation overflow (#8416)
Andrew Huang6d96a9565e74
diff --git a/frontend/src/components/v3/generic/AlertDialog/AlertDialog.stories.tsx b/frontend/src/components/v3/generic/AlertDialog/AlertDialog.stories.tsxindex 4d867004a7..141cb45379 100644--- a/frontend/src/components/v3/generic/AlertDialog/AlertDialog.stories.tsx+++ b/frontend/src/components/v3/generic/AlertDialog/AlertDialog.stories.tsx@@ -395,3 +395,31 @@ export const TypedConfirmation: Story = {},render: () => <TypedConfirmationStory />};++export const LongConfirmation: Story = {+ name: "Example: Long Confirmation",+ render: () => {+ const value = "AWS_REGION_PRODUCTION_PRIMARY_CLUSTER_".repeat(6);+ return (+ <AlertDialog confirmationValue={value}>+ <AlertDialogTrigger asChild>+ <Button variant="danger">Delete secret</Button>+ </AlertDialogTrigger>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Are you sure you want to delete {value}?</AlertDialogTitle>+ <AlertDialogDescription>+ This will permanently remove the secret from this environment. This action cannot be+ undone.+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogConfirmationField />+ <AlertDialogFooter>+ <AlertDialogCancel>Cancel</AlertDialogCancel>+ <AlertDialogAction variant="danger">Delete secret</AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>+ );+ }+};diff --git a/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx b/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsxindex 96c2a416ef..e33e86ff6e 100644--- a/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx+++ b/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx@@ -6,6 +6,7 @@ import { Button } from "../Button";import { DIALOG_CONTENT_WIDTH_CLASSNAME } from "../Dialog";import { Field, FieldLabel } from "../Field";import { Input } from "../Input";+import { Tooltip, TooltipContent, TooltipTrigger } from "../Tooltip";type AlertDialogConfirmationContextValue = {actionRef: React.MutableRefObject<HTMLButtonElement | null>;@@ -174,7 +175,7 @@ function AlertDialogTitle({<AlertDialogPrimitive.Titledata-slot="alert-dialog-title"className={cn(- "font-alliance text-lg font-normal sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",+ "line-clamp-2 min-w-0 font-alliance text-lg font-normal [overflow-wrap:anywhere] sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",className)}{...props}@@ -205,18 +206,86 @@ function AlertDialogConfirmationLabel({}: Omit<React.ComponentProps<typeof FieldLabel>, "children"> & {confirmationValue: React.ReactNode;}) {+ const [copyStatus, setCopyStatus] = React.useState("");+ const [tooltipOpen, setTooltipOpen] = React.useState(false);+ const copyPending = React.useRef(false);+ const copyGeneration = React.useRef(0);++ React.useEffect(() => {+ setCopyStatus("");+ setTooltipOpen(false);+ copyGeneration.current += 1;+ return () => {+ copyGeneration.current += 1;+ };+ }, [confirmationValue]);+return (- <FieldLabel- data-slot="alert-dialog-confirmation-label"- size="sm"- className={cn("gap-0", className)}- {...props}- >- <span>- Type "<span className="font-medium text-foreground">{confirmationValue}</span>" to- confirm.- </span>- </FieldLabel>+ <div className="min-w-0 space-y-1">+ <div className="flex min-w-0 items-baseline gap-1.5">+ <FieldLabel+ data-slot="alert-dialog-confirmation-label"+ size="sm"+ className={cn("shrink-0 gap-0", className)}+ {...props}+ >+ <span>+ Type the following to confirm:<span className="sr-only"> {confirmationValue}</span>+ </span>+ </FieldLabel>+ {typeof confirmationValue === "string" ? (+ <Tooltip open={tooltipOpen} onOpenChange={setTooltipOpen}>+ <TooltipTrigger asChild>+ <Button+ variant="text"+ className="max-w-full min-w-0 shrink justify-start text-left"+ aria-label={`Copy confirmation value: ${confirmationValue}`}+ onClick={async () => {+ if (copyPending.current) return;+ copyPending.current = true;+ setCopyStatus("");+ const generation = copyGeneration.current;+ try {+ await navigator.clipboard.writeText(confirmationValue);+ if (generation === copyGeneration.current) {+ setCopyStatus("Copied");+ setTooltipOpen(true);+ }+ } catch {+ if (generation === copyGeneration.current)+ setCopyStatus("Unable to copy. Select and copy the value manually.");+ } finally {+ copyPending.current = false;+ }+ }}+ >+ <span className="truncate font-mono font-medium select-text">+ {confirmationValue}+ </span>+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ {copyStatus.startsWith("Unable to copy")+ ? "Unable to copy"+ : copyStatus || "Click to copy"}+ </TooltipContent>+ </Tooltip>+ ) : (+ <div className="min-w-0 truncate font-medium">{confirmationValue}</div>+ )}+ </div>+ <div role="status" className="sr-only">+ {copyStatus}+ </div>+ {copyStatus.startsWith("Unable to copy") && typeof confirmationValue === "string" && (+ <div className="space-y-1">+ <p className="text-xs text-label">{copyStatus}</p>+ <div className="max-h-32 overflow-y-auto rounded-md border border-border bg-container p-2 font-mono text-sm [overflow-wrap:anywhere] select-text">+ {confirmationValue}+ </div>+ </div>+ )}+ </div>);}diff --git a/frontend/src/components/v3/generic/Button/Button.stories.tsx b/frontend/src/components/v3/generic/Button/Button.stories.tsxindex 39cb54a7c8..042cc03af5 100644--- a/frontend/src/components/v3/generic/Button/Button.stories.tsx+++ b/frontend/src/components/v3/generic/Button/Button.stories.tsx@@ -35,6 +35,7 @@ const meta = {"outline","ghost","link",+ "text","neutral","success","info",@@ -90,6 +91,22 @@ export const Outline: Story = {}};+export const Text: Story = {+ name: "Variant: Text",+ args: {+ variant: "text",+ children: "Copy value"+ },+ parameters: {+ docs: {+ description: {+ story:+ "Use for compact text actions without padding or an underline. Hover and pressed colors indicate interaction; keyboard focus remains visible."+ }+ }+ }+};+export const WithCornerBadge: Story = {name: "Composition: Corner Badge",render: () => (diff --git a/frontend/src/components/v3/generic/Button/Button.tsx b/frontend/src/components/v3/generic/Button/Button.tsxindex 18c9eb0753..e711946f3e 100644--- a/frontend/src/components/v3/generic/Button/Button.tsx+++ b/frontend/src/components/v3/generic/Button/Button.tsx@@ -23,6 +23,7 @@ const buttonVariants = cva(ghost:"text-foreground hover:bg-foreground/10 border-transparent data-[state=open]:bg-foreground/10 [--control-variant-color:var(--color-foreground)] [--control-variant-border-color:transparent]",link: "h-auto! rounded-none border-transparent bg-transparent p-0! text-foreground hover:bg-transparent hover:underline data-[state=open]:bg-transparent active:scale-100 [--control-variant-color:var(--color-foreground)] [--control-variant-border-color:transparent]",+ text: "h-auto! rounded-none border-0 bg-transparent p-0! text-foreground hover:text-accent active:text-muted active:scale-100 [--control-variant-color:var(--color-foreground)] [--control-variant-border-color:transparent]",neutral:"border-neutral/25 bg-neutral/10 text-foreground hover:bg-neutral/15 hover:border-neutral/30 data-[state=open]:bg-neutral/15 data-[state=open]:border-neutral/30 [--control-variant-color:var(--color-neutral)] [--control-variant-border-color:color-mix(in_oklab,var(--color-neutral)_25%,transparent)] hover:[--control-variant-border-color:color-mix(in_oklab,var(--color-neutral)_30%,transparent)] data-[state=open]:[--control-variant-border-color:color-mix(in_oklab,var(--color-neutral)_30%,transparent)]",project: