|
1 | 1 | import { Popover } from '@radix-ui/react-popover'; |
| 2 | +import * as PopoverPrimitive from '@radix-ui/react-popover'; |
2 | 3 | import { Check as DefaultCheckIcon, ChevronDown as DefaultChevronIcon } from 'lucide-react'; |
3 | 4 | import * as React from 'react'; |
4 | 5 | import { useOverlayTriggerState } from 'react-stately'; |
5 | | -import { PopoverContent, PopoverTrigger } from './popover'; |
| 6 | +import { PopoverTrigger } from './popover'; |
6 | 7 | import { cn } from './utils'; |
7 | 8 |
|
8 | 9 | export interface SelectOption { |
@@ -149,14 +150,26 @@ export function Select({ |
149 | 150 | <ChevronIcon className="w-4 h-4 opacity-50" /> |
150 | 151 | </Trigger> |
151 | 152 | </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 | + > |
160 | 173 | <div className="bg-white p-1.5 rounded-md focus:outline-none sm:text-sm"> |
161 | 174 | <div className="px-1.5 pb-1.5"> |
162 | 175 | <SearchInput |
@@ -227,7 +240,8 @@ export function Select({ |
227 | 240 | })} |
228 | 241 | </ul> |
229 | 242 | </div> |
230 | | - </PopoverContent> |
| 243 | + </PopoverPrimitive.Content> |
| 244 | + </PopoverPrimitive.Portal> |
231 | 245 | </Popover> |
232 | 246 | ); |
233 | 247 | } |
0 commit comments