Skip to content

Commit c3b95a9

Browse files
committed
fix: removed combobox fix for scroll
1 parent afd5fed commit c3b95a9

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

packages/react/src/components/ui/combobox.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ export function Combobox({
5656
const reactId = React.useId();
5757
const inputId = `combobox-input-${reactId}`;
5858

59+
const [popoverContainer, setPopoverContainer] = React.useState<HTMLElement | null>(null);
60+
61+
React.useEffect(() => {
62+
if (!open) return;
63+
const dialogContent = containerRef.current?.closest<HTMLElement>(
64+
'[data-slot="dialog-content"]',
65+
);
66+
setPopoverContainer(dialogContent ?? portalContainer);
67+
}, [open, portalContainer]);
68+
5969
const selectedValues = React.useMemo(() => {
6070
if (multiple) {
6171
return Array.isArray(value) ? value : value ? [value] : [];
@@ -511,7 +521,7 @@ export function Combobox({
511521
</PopoverPrimitive.Trigger>
512522
</div>
513523

514-
<PopoverPrimitive.Portal container={portalContainer}>
524+
<PopoverPrimitive.Portal container={popoverContainer}>
515525
<PopoverPrimitive.Content
516526
className="bg-popover text-popover-foreground shadow-bevel-xl data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 min-w-[var(--radix-popover-trigger-width)] overflow-hidden rounded-3xl ring-0 duration-300 ease-in-out outline-none focus:outline-none"
517527
align="start"

0 commit comments

Comments
 (0)