Skip to content

Commit e1409b7

Browse files
Fix dropdown width by removing hardcoded w-72 class
- Replace PopoverContent with direct PopoverPrimitive.Content usage - Remove hardcoded w-72 (288px) width that was overriding inline styles - Maintain all popover animations and positioning behavior - Now the inline width style can properly control dropdown width - This should fix the width matching issue where dropdown was stuck at 288px
1 parent 8f0ebc9 commit e1409b7

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

packages/components/src/ui/select.tsx

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Popover } from '@radix-ui/react-popover';
2+
import * as PopoverPrimitive from '@radix-ui/react-popover';
23
import { Check as DefaultCheckIcon, ChevronDown as DefaultChevronIcon } from 'lucide-react';
34
import * as React from 'react';
45
import { useOverlayTriggerState } from 'react-stately';
5-
import { PopoverContent, PopoverTrigger } from './popover';
6+
import { PopoverTrigger } from './popover';
67
import { cn } from './utils';
78

89
export interface SelectOption {
@@ -149,14 +150,26 @@ export function Select({
149150
<ChevronIcon className="w-4 h-4 opacity-50" />
150151
</Trigger>
151152
</PopoverTrigger>
152-
<PopoverContent
153-
ref={popoverRef}
154-
className={cn('z-50 p-0 shadow-md border-0', contentClassName)}
155-
// biome-ignore lint/a11y/useSemanticElements: using <div> for PopoverContent to ensure keyboard accessibility and focus management
156-
role="listbox"
157-
id={listboxId}
158-
style={{ width: menuWidth ? `${menuWidth}px` : undefined }}
159-
>
153+
<PopoverPrimitive.Portal>
154+
<PopoverPrimitive.Content
155+
ref={popoverRef}
156+
align="start"
157+
sideOffset={4}
158+
className={cn(
159+
'z-50 rounded-md border bg-popover text-popover-foreground shadow-md outline-none',
160+
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
161+
'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
162+
'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2',
163+
'data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
164+
'p-0 shadow-md border-0',
165+
contentClassName
166+
)}
167+
// biome-ignore lint/a11y/useSemanticElements: using <div> for PopoverContent to ensure keyboard accessibility and focus management
168+
role="listbox"
169+
id={listboxId}
170+
style={{ width: menuWidth ? `${menuWidth}px` : undefined }}
171+
data-slot="popover-content"
172+
>
160173
<div className="bg-white p-1.5 rounded-md focus:outline-none sm:text-sm">
161174
<div className="px-1.5 pb-1.5">
162175
<SearchInput
@@ -227,7 +240,8 @@ export function Select({
227240
})}
228241
</ul>
229242
</div>
230-
</PopoverContent>
243+
</PopoverPrimitive.Content>
244+
</PopoverPrimitive.Portal>
231245
</Popover>
232246
);
233247
}

0 commit comments

Comments
 (0)