From dff1e8d1a7ed7d26f1bb95dbce1a5843d3b9d386 Mon Sep 17 00:00:00 2001 From: kovakmedya Date: Thu, 21 May 2026 22:09:49 +0300 Subject: [PATCH] fix(ui): Select trigger fills container, dropdown matches trigger width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shadcn template ships SelectTrigger with 'w-fit' so the control sizes to its content. That works for headless toolbar pickers but in our forms the Select sits in a grid column next to Inputs of the same row — the 'w-fit' behaviour made labs/patients/products dropdowns visibly narrower than their neighbouring fields. Switched the trigger default to 'w-full' so column layouts stay tidy; anything that genuinely wants content-width can still override via className. Also fixed SelectContent: the Radix portal was capped at 'min-w-[8rem]' which can be narrower than the trigger and the popper would dock to that fixed 128px rather than the field. Replaced with 'min-w-[var(--radix-select-trigger-width)]' so the dropdown is always at least as wide as the field it dropped from. --- src/components/ui/select.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ui/select.tsx b/src/components/ui/select.tsx index 51f466e..f8a184a 100644 --- a/src/components/ui/select.tsx +++ b/src/components/ui/select.tsx @@ -35,7 +35,7 @@ function SelectTrigger({ data-slot="select-trigger" data-size={size} className={cn( - "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", + "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className )} {...props} @@ -59,7 +59,7 @@ function SelectContent({