fix: cap dialog grid column so fields cannot overflow the modal
Some checks failed
Deploy to Production / Trigger production update (push) Failing after 10s
SonarCloud / SonarCloud Analysis (push) Failing after 2m20s

The dialog body is a grid whose implicit column is auto-sized, i.e.
max-content. Long unbreakable option labels (e.g. CT template file
names) widened that column and pushed the select fields and footer
buttons past the dialog edge.

Use grid-cols-[minmax(0,1fr)] on DialogContent to cap the track at the
dialog width, and apply the same guard to the Alert grid template.
Verified: dialog scrollWidth now equals clientWidth at both 1280px and
375px viewports, with no horizontal page overflow.
This commit is contained in:
2026-08-19 17:36:20 +05:00
parent 5bb349564f
commit 0db2f340f6
2 changed files with 6 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils"
const alertVariants = cva( const alertVariants = cva(
"relative grid w-full grid-cols-[0_1fr] items-start gap-x-2.5 gap-y-1 rounded-lg border px-3.5 py-3 text-sm has-[>svg]:grid-cols-[theme(spacing.4)_1fr] [&>svg]:mt-0.5 [&>svg]:size-4", "relative grid w-full grid-cols-[0_minmax(0,1fr)] items-start gap-x-2.5 gap-y-1 rounded-lg border px-3.5 py-3 text-sm has-[>svg]:grid-cols-[theme(spacing.4)_minmax(0,1fr)] [&>svg]:mt-0.5 [&>svg]:size-4",
{ {
variants: { variants: {
variant: { variant: {

View File

@@ -55,7 +55,11 @@ function DialogContent({
className={cn( className={cn(
// Default width: capped at max-w-lg and centered; on small screens w-[calc(100%-2rem)] // Default width: capped at max-w-lg and centered; on small screens w-[calc(100%-2rem)]
// keeps a 1rem gap on each side. Individual dialogs override width via their own max-w-*. // keeps a 1rem gap on each side. Individual dialogs override width via their own max-w-*.
"fixed top-1/2 left-1/2 z-50 grid w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", // grid-cols-[minmax(0,1fr)] caps the implicit column at the dialog
// width: an `auto` track is max-content sized, so long unbreakable
// content (e.g. CT template names) would otherwise widen the column
// and push fields past the dialog edge.
"fixed top-1/2 left-1/2 z-50 grid w-[calc(100%-2rem)] max-w-lg grid-cols-[minmax(0,1fr)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
className className
)} )}
{...props} {...props}