File tree Expand file tree Collapse file tree
packages/react/src/components/ui Expand file tree Collapse file tree Original file line number Diff line number Diff 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"
You can’t perform that action at this time.
0 commit comments