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(announcements): stabilize modal height and image loading (#8042)
Andrew Huange242b13d37c7
diff --git a/frontend/src/assets/gradients/gradient-certificates.png b/frontend/src/assets/gradients/gradient-certificates.pngnew file mode 100644index 0000000000..7c44102a87Binary files /dev/null and b/frontend/src/assets/gradients/gradient-certificates.png differdiff --git a/frontend/src/assets/gradients/gradient-mesh.png b/frontend/src/assets/gradients/gradient-mesh.pngnew file mode 100644index 0000000000..e3cae8afc2Binary files /dev/null and b/frontend/src/assets/gradients/gradient-mesh.png differdiff --git a/frontend/src/assets/gradients/gradient-pam.png b/frontend/src/assets/gradients/gradient-pam.pngnew file mode 100644index 0000000000..ee56d4bfa4Binary files /dev/null and b/frontend/src/assets/gradients/gradient-pam.png differdiff --git a/frontend/src/assets/gradients/gradient-secrets.png b/frontend/src/assets/gradients/gradient-secrets.pngnew file mode 100644index 0000000000..2a6ae5182bBinary files /dev/null and b/frontend/src/assets/gradients/gradient-secrets.png differdiff --git a/frontend/src/components/announcements/AnnouncementModal.tsx b/frontend/src/components/announcements/AnnouncementModal.tsxindex bde2e0028a..9135396904 100644--- a/frontend/src/components/announcements/AnnouncementModal.tsx+++ b/frontend/src/components/announcements/AnnouncementModal.tsx@@ -1,15 +1,17 @@-import { useEffect, useState } from "react";-import { ChevronLeft, ChevronRight, ExternalLink } from "lucide-react";+import { KeyboardEvent, useEffect, useRef, useState } from "react";+import { ChevronLeft, ChevronRight, ExternalLink, XIcon } from "lucide-react";+import gradientMesh from "@app/assets/gradients/gradient-mesh.png";import {Button,Dialog,+ DialogClose,DialogContent,DialogDescription,- DialogHeader,DialogTitle,IconButton} from "@app/components/v3";+import { cn } from "@app/components/v3/utils";import { TAnnouncement } from "@app/hooks/api/announcement";type Props = {@@ -32,6 +34,7 @@ const formatPublished = (iso: string) => {// Belt to the server-side allowlist: refuse anything that isn't an http(s) URL// so a stale self-hosted bundle can't sneak a `javascript:` href into <a>.const ALLOWED_LINK_PROTOCOLS = new Set(["http:", "https:"]);+const TEXT_ENTRY_SELECTOR = 'input, textarea, select, [contenteditable="true"]';const safeLink = (link: string | null): string | null => {if (!link) return null;try {@@ -42,97 +45,265 @@ const safeLink = (link: string | null): string | null => {}};-export const AnnouncementModal = ({ announcements, isOpen, onOpenChange }: Props) => {- const [index, setIndex] = useState(0);+const AnnouncementImage = ({ src }: { src: string }) => {+ const [status, setStatus] = useState<"loading" | "loaded" | "error">("loading");- useEffect(() => {- if (isOpen) setIndex(0);- }, [isOpen]);-- const total = announcements.length;- const safeIndex = Math.min(index, total - 1);- const announcement = announcements[safeIndex];- if (!announcement) return null;+ return (+ <div className="relative aspect-[16/9] w-full overflow-hidden bg-container">+ {status !== "loaded" && (+ <div+ role="status"+ className="absolute inset-0 flex items-center justify-center text-sm text-muted"+ >+ {status === "error" ? "Image unavailable" : "Loading image…"}+ </div>+ )}+ <img+ src={src}+ alt=""+ loading="eager"+ onLoad={() => setStatus("loaded")}+ onError={() => setStatus("error")}+ className={+ status === "loaded"+ ? "absolute inset-0 h-full w-full object-cover"+ : "invisible absolute inset-0 h-full w-full object-cover"+ }+ />+ </div>+ );+};+const AnnouncementCard = ({+ announcement,+ offset,+ onNavigate+}: {+ announcement: TAnnouncement;+ offset: number;+ onNavigate: (direction: number) => void;+}) => {+ const cardRef = useRef<HTMLDivElement | null>(null);+ const [isHighlighted, setIsHighlighted] = useState(false);+ const isActive = offset === 0;const safeHref = safeLink(announcement.link);+ const imageSrc = announcement.imageUrl ?? gradientMesh;const ctaLabel = announcement.linkLabel || (safeHref ? "Learn more" : null);const publishedLabel = formatPublished(announcement.published);- const hasPrev = safeIndex > 0;- const hasNext = safeIndex < total - 1;- const showPager = total > 1;+ const Title = isActive ? DialogTitle : "h2";+ const Description = isActive ? DialogDescription : "p";+ const previewTransform = (distance: number) =>+ `translateX(${Math.sign(offset) * distance}px) scale(0.96) rotate(${Math.sign(offset)}deg)`;++ useEffect(() => {+ if (isActive && cardRef.current) cardRef.current.scrollTop = 0;+ }, [isActive]);++ useEffect(() => {+ setIsHighlighted(false);+ }, [offset]);return (- <Dialog open={isOpen} onOpenChange={onOpenChange}>- <DialogContent className="max-w-xl overflow-hidden p-0">- {announcement.imageUrl && (- <div className="aspect-[16/9] w-full overflow-hidden bg-muted">- <img- src={announcement.imageUrl}- alt=""- loading="eager"- className="h-full w-full object-cover"- />- </div>+ <>+ <div+ data-announcement-card+ ref={(node) => {+ cardRef.current = node;+ node?.toggleAttribute("inert", !isActive);+ }}+ aria-hidden={!isActive}+ role="region"+ aria-label={announcement.title}+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- The scrollable card needs keyboard focus so its full content is reachable.+ tabIndex={isActive ? 0 : -1}+ className={cn(+ "absolute inset-0 thin-scrollbar overflow-x-hidden overflow-y-auto overscroll-none rounded-lg border border-border bg-popover shadow-lg transition-[transform,filter] duration-300 ease-[cubic-bezier(0.32,0.72,0,1)] outline-none focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none",+ isActive ? "pointer-events-auto" : "pointer-events-none select-none",+ Math.abs(offset) > 1 && "invisible")}- <div className="flex flex-col gap-4 p-4">- <DialogHeader>+ style={{+ zIndex: isActive ? 20 : 10 - Math.abs(offset),+ filter: !isActive && isHighlighted ? "brightness(1.1)" : "brightness(1)",+ transform: isActive+ ? "translateX(0) scale(1) rotate(0deg)"+ : previewTransform(isHighlighted ? 40 : 32)+ }}+ >+ <div+ className="transition-[filter] duration-300 ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none"+ style={{ filter: isActive ? "blur(0px)" : "blur(3px)" }}+ >+ <AnnouncementImage key={imageSrc} src={imageSrc} />+ <div className="flex flex-col gap-3 px-4 py-8 @lg/announcements:px-6">{publishedLabel && (- <time- dateTime={announcement.published}- className="text-xs font-medium tracking-wide text-muted uppercase"- >+ <time dateTime={announcement.published} className="text-xs text-accent">{publishedLabel}</time>)}- <DialogTitle>{announcement.title}</DialogTitle>- <DialogDescription className="my-4 whitespace-pre-line text-foreground/75">+ <Title className="text-lg leading-snug font-semibold wrap-anywhere">+ {announcement.title}+ </Title>+ <Description className="my-2 text-sm wrap-anywhere whitespace-pre-line text-accent">{announcement.body}- </DialogDescription>+ </Description>{safeHref && ctaLabel && (<ahref={safeHref}+ tabIndex={isActive ? undefined : -1}target="_blank"rel="noopener noreferrer"- className="inline-flex w-fit items-center gap-1.5 text-sm text-white underline"+ className="inline-flex w-fit items-center gap-1.5 text-sm text-foreground underline outline-none focus-visible:ring-2 focus-visible:ring-ring">- {ctaLabel}- <ExternalLink className="size-3.5" />+ <span className="wrap-anywhere">{ctaLabel}</span>+ <ExternalLink className="size-3.5 shrink-0" /></a>)}- </DialogHeader>- <div className="flex items-center justify-between gap-2">- {showPager ? (- <div className="flex items-center gap-1.5 text-sm text-muted">- <IconButton- variant="ghost"- size="xs"- aria-label="Previous announcement"- onClick={() => setIndex(Math.max(0, safeIndex - 1))}- isDisabled={!hasPrev}- >- <ChevronLeft />- </IconButton>- <span className="tabular-nums">- {safeIndex + 1} / {total}- </span>- <IconButton- variant="ghost"- size="xs"- aria-label="Next announcement"- onClick={() => setIndex(Math.min(total - 1, safeIndex + 1))}- isDisabled={!hasNext}- >- <ChevronRight />- </IconButton>- </div>- ) : (- <span aria-hidden="true" />- )}- <Button variant="outline" onClick={() => onOpenChange(false)}>- Got it- </Button></div></div>+ </div>+ {Math.abs(offset) === 1 && (+ <Button+ data-announcement-preview+ variant="ghost"+ aria-label={`Show ${offset < 0 ? "previous" : "next"} announcement: ${announcement.title}`}+ className="pointer-events-auto absolute inset-0 z-10 h-full w-full rounded-lg border-0 bg-transparent p-0 transition-none hover:bg-transparent active:scale-100"+ style={{ transform: previewTransform(40) }}+ onPointerEnter={(event) => {+ if (event.pointerType !== "touch") setIsHighlighted(true);+ }}+ onPointerLeave={() => setIsHighlighted(false)}+ onFocus={() => setIsHighlighted(true)}+ onBlur={() => setIsHighlighted(false)}+ onClick={(event) => {+ event.currentTarget+ .closest<HTMLElement>('[role="dialog"]')+ ?.focus({ preventScroll: true });+ onNavigate(Math.sign(offset));+ }}+ />+ )}+ </>+ );+};++export const AnnouncementModal = ({ announcements, isOpen, onOpenChange }: Props) => {+ const [index, setIndex] = useState(0);++ useEffect(() => {+ if (isOpen) setIndex(0);+ }, [isOpen]);++ const total = announcements.length;+ const safeIndex = Math.min(index, total - 1);+ const announcement = announcements[safeIndex];+ if (!announcement) return null;++ const hasPrev = safeIndex > 0;+ const hasNext = safeIndex < total - 1;+ const showPager = total > 1;++ const navigate = (direction: number) => {+ setIndex((current) =>+ Math.max(0, Math.min(total - 1, Math.min(current, total - 1) + direction))+ );+ };++ const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {+ if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.altKey) return;+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;+ if ((event.target as HTMLElement | null)?.closest(TEXT_ENTRY_SELECTOR)) return;++ if (event.key === "ArrowLeft" && hasPrev) {+ event.preventDefault();+ if (+ (event.target as HTMLElement).closest(+ "[data-announcement-card], [data-announcement-preview]"+ )+ ) {+ event.currentTarget.focus();+ }+ navigate(-1);+ } else if (event.key === "ArrowRight" && hasNext) {+ event.preventDefault();+ if (+ (event.target as HTMLElement).closest(+ "[data-announcement-card], [data-announcement-preview]"+ )+ ) {+ event.currentTarget.focus();+ }+ navigate(1);+ }+ };++ return (+ <Dialog open={isOpen} onOpenChange={onOpenChange}>+ <DialogContent+ showCloseButton={false}+ height="fixed"+ className="@container/announcements pointer-events-none w-[calc(100%-1rem)] max-w-4xl gap-0 overflow-visible border-0 bg-transparent p-0 shadow-none motion-reduce:animate-none"+ onKeyDown={handleKeyDown}+ >+ <div+ className={cn(+ "relative mx-auto h-full min-h-0 w-[calc(100%-7rem)] max-w-xl",+ !showPager && "w-full"+ )}+ >+ {announcements.slice(Math.max(0, safeIndex - 2), safeIndex + 3).map((item, itemIndex) => (+ <AnnouncementCard+ key={item.id}+ announcement={item}+ offset={Math.max(0, safeIndex - 2) + itemIndex - safeIndex}+ onNavigate={navigate}+ />+ ))}+ <DialogClose asChild>+ <IconButton+ aria-label="Close"+ variant="ghost"+ size="xs"+ className="pointer-events-auto absolute top-3 right-3 z-30 bg-popover/80 backdrop-blur-sm hover:bg-container-hover"+ >+ <XIcon />+ </IconButton>+ </DialogClose>+ {showPager && (+ <span+ aria-hidden="true"+ className="pointer-events-none absolute top-3 left-3 z-30 rounded-full border border-border bg-popover/80 px-2.5 py-1 text-xs text-accent tabular-nums backdrop-blur-sm"+ >+ {safeIndex + 1} / {total}+ </span>+ )}+ {showPager && (+ <>+ <IconButton+ variant="ghost"+ size="md"+ aria-label="Previous announcement"+ aria-disabled={!hasPrev}+ onClick={() => hasPrev && navigate(-1)}+ className="pointer-events-auto absolute top-1/2 -left-14 z-30 size-11 -translate-y-1/2 transition-[color,background-color,transform] aria-disabled:cursor-default aria-disabled:opacity-30 motion-reduce:transition-none [&>svg]:size-5"+ >+ <ChevronLeft />+ </IconButton>+ <IconButton+ variant="ghost"+ size="md"+ aria-label="Next announcement"+ aria-disabled={!hasNext}+ onClick={() => hasNext && navigate(1)}+ className="pointer-events-auto absolute top-1/2 -right-14 z-30 size-11 -translate-y-1/2 transition-[color,background-color,transform] aria-disabled:cursor-default aria-disabled:opacity-30 motion-reduce:transition-none [&>svg]:size-5"+ >+ <ChevronRight />+ </IconButton>+ </>+ )}+ </div>+ <span role="status" aria-live="polite" aria-atomic="true" className="sr-only">+ Announcement {safeIndex + 1} of {total}: {announcement.title}+ </span></DialogContent></Dialog>);diff --git a/frontend/src/components/v3/generic/Dialog/Dialog.stories.tsx b/frontend/src/components/v3/generic/Dialog/Dialog.stories.tsxindex 3a02a68936..87981cdf76 100644--- a/frontend/src/components/v3/generic/Dialog/Dialog.stories.tsx+++ b/frontend/src/components/v3/generic/Dialog/Dialog.stories.tsx@@ -75,6 +75,37 @@ export const Default: Story = {)};+export const FixedHeight: Story = {+ name: "Variant: Fixed Height",+ parameters: {+ docs: {+ description: {+ story:+ 'Use height="fixed" for changing content such as announcement slides. The dialog reserves 40rem, capped to the available viewport height. Keep scrolling content in DialogBody and actions in DialogFooter; the default padding, spacing, and footer styling are preserved.'+ }+ }+ },+ render: () => (+ <Dialog>+ <DialogTrigger asChild>+ <Button variant="outline">Open Fixed Height Dialog</Button>+ </DialogTrigger>+ <DialogContent height="fixed">+ <DialogHeader>+ <DialogTitle>What's New</DialogTitle>+ <DialogDescription>Review the latest updates.</DialogDescription>+ </DialogHeader>+ <DialogBody>Short content keeps the same dialog height as longer content.</DialogBody>+ <DialogFooter>+ <DialogClose asChild>+ <Button variant="outline">Close</Button>+ </DialogClose>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ )+};+export const WithForm: Story = {name: "Example: With Form",parameters: {diff --git a/frontend/src/components/v3/generic/Dialog/Dialog.tsx b/frontend/src/components/v3/generic/Dialog/Dialog.tsxindex 183276c00d..59c6635cb0 100644--- a/frontend/src/components/v3/generic/Dialog/Dialog.tsx+++ b/frontend/src/components/v3/generic/Dialog/Dialog.tsx@@ -49,12 +49,14 @@ function DialogContent({className,children,showCloseButton = true,+ height = "auto",onPointerDownOutside,onInteractOutside,overlayClassName,...props}: React.ComponentProps<typeof DialogPrimitive.Content> & {showCloseButton?: boolean;+ height?: "auto" | "fixed";overlayClassName?: string;}) {return (@@ -65,6 +67,7 @@ function DialogContent({className={cn("fixed top-[50%] left-[50%] z-50 flex max-h-[calc(100dvh-2rem)] thin-scrollbar translate-x-[-50%] translate-y-[-50%] flex-col gap-6 overflow-y-auto overscroll-none rounded-lg border border-border bg-popover p-6 text-foreground shadow-lg outline-none has-data-[slot=dialog-footer]:pb-0 data-[state=closed]:animate-out data-[state=closed]:duration-100 data-[state=closed]:ease-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:duration-150 data-[state=open]:ease-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",DIALOG_CONTENT_WIDTH_CLASSNAME,+ height === "fixed" && "h-[40rem] overflow-hidden",className)}onPointerDownOutside={(e) => {diff --git a/frontend/src/components/v3/platform/AnnouncementModal.stories.tsx b/frontend/src/components/v3/platform/AnnouncementModal.stories.tsxnew file mode 100644index 0000000000..216e7d3815--- /dev/null+++ b/frontend/src/components/v3/platform/AnnouncementModal.stories.tsx@@ -0,0 +1,97 @@+import { useState } from "react";+import type { Meta, StoryObj } from "@storybook/react-vite";++import { AnnouncementModal } from "@app/components/announcements/AnnouncementModal";++import { Button } from "../generic/Button";++const meta = {+ title: "Platform/AnnouncementModal",+ component: AnnouncementModal,+ tags: ["autodocs"],+ args: {+ isOpen: true,+ onOpenChange: () => {},+ announcements: [+ {+ id: "short",+ title: "Product Updates",+ body: "Review the latest updates to Infisical.",+ imageUrl:+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='450'%3E%3Crect width='800' height='450' fill='white'/%3E%3C/svg%3E",+ link: "https://infisical.com",+ linkLabel: "Read More",+ published: "2026-09-10T00:00:00Z"+ },+ {+ id: "long",+ title: "More Updates",+ body: "Long announcement content remains scrollable while navigation stays visible.\n\n".repeat(+ 30+ ),+ imageUrl: null,+ link: null,+ linkLabel: null,+ published: "2026-09-09T00:00:00Z"+ },+ {+ id: "unavailable",+ title: "Unavailable Artwork",+ body: "You can still read this announcement and navigate when artwork fails to load.",+ imageUrl: "data:image/png;base64,invalid",+ link: null,+ linkLabel: null,+ published: "2026-09-08T00:00:00Z"+ }+ ]+ }+} satisfies Meta<typeof AnnouncementModal>;++export default meta;+type Story = StoryObj<typeof meta>;++export const Default: Story = {+ name: "Example: Announcement Navigation",+ parameters: {+ docs: {+ description: {+ story:+ "Side arrows sit 12px from the card and bring adjacent previews into the center. Previews use a fixed 32px offset. Only their artwork and text blur as they recede, then sharpen as they become active; card surfaces and borders stay sharp. Hover or focus a preview to move it outward another 8px and brighten it; select it to navigate. Pointer and arrow-key navigation share the transition; reduced motion disables it. The card has no footer; close it with the top-right button, Escape, or the backdrop. Long content scrolls independently of the controls."+ }+ }+ },+ render: function Render(args) {+ const [isOpen, setIsOpen] = useState(args.isOpen);++ return (+ <>+ <Button variant="outline" onClick={() => setIsOpen(true)}>+ Open Announcements+ </Button>+ <AnnouncementModal {...args} isOpen={isOpen} onOpenChange={setIsOpen} />+ </>+ );+ }+};++export const SingleAnnouncement: Story = {+ ...Default,+ name: "Example: Single Announcement",+ args: {+ announcements: [meta.args.announcements[0]]+ }+};++export const LongTitle: Story = {+ ...Default,+ name: "State: Long Title",+ args: {+ announcements: [+ {+ ...meta.args.announcements[0],+ title: "New Controls for Managing Secrets Across Your Organization and Projects"+ },+ ...meta.args.announcements.slice(1)+ ]+ }+};