@@ -60,6 +60,7 @@ import { ItemBase } from '../../content/ItemBase';
6060import { useFieldProps , useFormProps , wrapWithField } from '../../form' ;
6161import { DisplayTransition } from '../../helpers' ;
6262import { Item } from '../../Item' ;
63+ import { Portal } from '../../portal' ;
6364import { InvalidIcon } from '../../shared/InvalidIcon' ;
6465import { ValidIcon } from '../../shared/ValidIcon' ;
6566
@@ -546,87 +547,89 @@ export function ListBoxPopup({
546547 // <DismissButton> components at the start and end of the list
547548 // to allow screen reader users to dismiss the popup easily.
548549 return (
549- < DisplayTransition isShown = { state . isOpen && ! isDisabled } >
550- { ( { phase, isShown, ref : transitionRef } ) => (
551- < OverlayElement
552- { ...overlayProps }
553- { ...parentOverlayProps }
554- ref = { ( value ) => {
555- transitionRef ( value as HTMLElement | null ) ;
556- ( popoverRef as any ) . current = value ;
557- } }
558- data-placement = { placementDirection }
559- data-phase = { phase }
560- mods = { {
561- open : isShown ,
562- } }
563- styles = { overlayStyles }
564- style = { {
565- '--overlay-min-width' : minWidth ? `${ minWidth } px` : 'initial' ,
566- ...parentOverlayProps ?. style ,
567- } }
568- >
569- < FocusScope restoreFocus >
570- < DismissButton onDismiss = { ( ) => state . close ( ) } />
571- { ( ( ) => {
572- const renderedItems : React . ReactNode [ ] = [ ] ;
573- let isFirstSection = true ;
574-
575- for ( const item of state . collection ) {
576- if ( item . type === 'section' ) {
577- if ( ! isFirstSection ) {
550+ < Portal >
551+ < DisplayTransition isShown = { state . isOpen && ! isDisabled } >
552+ { ( { phase, isShown, ref : transitionRef } ) => (
553+ < OverlayElement
554+ { ...overlayProps }
555+ { ...parentOverlayProps }
556+ ref = { ( value ) => {
557+ transitionRef ( value as HTMLElement | null ) ;
558+ ( popoverRef as any ) . current = value ;
559+ } }
560+ data-placement = { placementDirection }
561+ data-phase = { phase }
562+ mods = { {
563+ open : isShown ,
564+ } }
565+ styles = { overlayStyles }
566+ style = { {
567+ '--overlay-min-width' : minWidth ? `${ minWidth } px` : 'initial' ,
568+ ...parentOverlayProps ?. style ,
569+ } }
570+ >
571+ < FocusScope restoreFocus >
572+ < DismissButton onDismiss = { ( ) => state . close ( ) } />
573+ { ( ( ) => {
574+ const renderedItems : React . ReactNode [ ] = [ ] ;
575+ let isFirstSection = true ;
576+
577+ for ( const item of state . collection ) {
578+ if ( item . type === 'section' ) {
579+ if ( ! isFirstSection ) {
580+ renderedItems . push (
581+ < ListDivider
582+ key = { `divider-${ String ( item . key ) } ` }
583+ as = "li"
584+ role = "separator"
585+ aria-orientation = "horizontal"
586+ /> ,
587+ ) ;
588+ }
589+
578590 renderedItems . push (
579- < ListDivider
580- key = { `divider-${ String ( item . key ) } ` }
581- as = "li"
582- role = "separator"
583- aria-orientation = "horizontal"
591+ < SelectSection
592+ key = { item . key }
593+ item = { item }
594+ state = { state }
595+ optionStyles = { optionStyles }
596+ sectionStyles = { undefined }
597+ shouldUseVirtualFocus = { shouldUseVirtualFocus }
598+ size = { listItemSize }
584599 /> ,
585600 ) ;
586- }
587601
588- renderedItems . push (
589- < SelectSection
590- key = { item . key }
591- item = { item }
592- state = { state }
593- optionStyles = { optionStyles }
594- sectionStyles = { undefined }
595- shouldUseVirtualFocus = { shouldUseVirtualFocus }
596- size = { listItemSize }
597- /> ,
598- ) ;
599-
600- isFirstSection = false ;
601- } else {
602- renderedItems . push (
603- < Option
604- key = { item . key }
605- item = { item }
606- state = { state }
607- styles = { optionStyles }
608- shouldUseVirtualFocus = { shouldUseVirtualFocus }
609- size = { listItemSize }
610- /> ,
611- ) ;
602+ isFirstSection = false ;
603+ } else {
604+ renderedItems . push (
605+ < Option
606+ key = { item . key }
607+ item = { item }
608+ state = { state }
609+ styles = { optionStyles }
610+ shouldUseVirtualFocus = { shouldUseVirtualFocus }
611+ size = { listItemSize }
612+ /> ,
613+ ) ;
614+ }
612615 }
613- }
614-
615- return (
616- < ListBoxElement
617- styles = { listBoxStyles }
618- { ... listBoxProps }
619- ref = { listBoxRef }
620- >
621- { renderedItems }
622- </ ListBoxElement >
623- ) ;
624- } ) ( ) }
625- < DismissButton onDismiss = { ( ) => state . close ( ) } / >
626- </ FocusScope >
627- </ OverlayElement >
628- ) }
629- </ DisplayTransition >
616+
617+ return (
618+ < ListBoxElement
619+ styles = { listBoxStyles }
620+ { ... listBoxProps }
621+ ref = { listBoxRef }
622+ >
623+ { renderedItems }
624+ </ ListBoxElement >
625+ ) ;
626+ } ) ( ) }
627+ < DismissButton onDismiss = { ( ) => state . close ( ) } />
628+ </ FocusScope >
629+ </ OverlayElement >
630+ ) }
631+ </ DisplayTransition >
632+ </ Portal >
630633 ) ;
631634}
632635
0 commit comments