@@ -23,14 +23,16 @@ import {
2323 MenuTriggerProps as AriaMenuTriggerProps ,
2424 SubmenuTrigger as AriaSubmenuTrigger ,
2525 SubmenuTriggerProps as AriaSubmenuTriggerProps ,
26- MenuItemRenderProps
26+ MenuItemRenderProps ,
27+ MenuStateContext
2728} from 'react-aria-components/Menu' ;
2829import {
2930 AsyncLoadable ,
3031 DOMRef ,
3132 DOMRefValue ,
3233 GlobalDOMAttributes ,
3334 LoadingState ,
35+ Node ,
3436 PressEvent
3537} from '@react-types/shared' ;
3638import {
@@ -57,6 +59,7 @@ import {
5759} from './style-utils' with { type : 'macro' } ;
5860import {
5961 createContext ,
62+ ForwardedRef ,
6063 forwardRef ,
6164 JSX ,
6265 ReactElement ,
@@ -65,6 +68,7 @@ import {
6568 useRef ,
6669 useState
6770} from 'react' ;
71+ import { createLeafComponent } from 'react-aria/CollectionBuilder' ;
6872import { divider } from './Divider' ;
6973import { edgeToText } from '../style/spectrum-theme' with { type : 'macro' } ;
7074import { forwardRefType } from './types' ;
@@ -74,6 +78,7 @@ import {ImageContext} from './Image';
7478import InfoCircleIcon from '../s2wf-icons/S2_Icon_InfoCircle_20_N.svg' ; // chevron right removed??
7579import { InPopoverContext , Popover , PopoverContext } from './Popover' ;
7680import intlMessages from '../intl/*.json' ;
81+ import { isSeparatorHidden , SeparatorNode } from './separator-utils' ;
7782import LinkOutIcon from '../ui-icons/LinkOut' ;
7883import { mergeStyles } from '../style/runtime' ;
7984import { Placement } from 'react-aria/useOverlayPosition' ;
@@ -585,29 +590,35 @@ export const Menu = /*#__PURE__*/ (forwardRef as forwardRefType)(function Menu<T
585590 return content ;
586591} ) ;
587592
588- export function Divider ( props : SeparatorProps ) : ReactNode {
589- return (
590- < Separator
591- { ...props }
592- className = { mergeStyles (
593- divider ( {
594- size : 'M' ,
595- orientation : 'horizontal' ,
596- isStaticColor : false
597- } ) ,
598- style ( {
599- display : {
600- default : 'grid' ,
601- ':last-child' : 'none'
602- } ,
603- gridColumnStart : 2 ,
604- gridColumnEnd : - 2 ,
605- marginY : size ( 5 ) // height of the menu separator is 12px, and the divider is 2px
606- } )
607- ) }
608- />
609- ) ;
610- }
593+ export const Divider = /*#__PURE__*/ createLeafComponent (
594+ SeparatorNode ,
595+ function Divider ( props : SeparatorProps , ref : ForwardedRef < HTMLElement > , node : Node < unknown > ) {
596+ let state = useContext ( MenuStateContext ) ! ;
597+
598+ if ( isSeparatorHidden ( node , state . collection ) ) {
599+ return null ;
600+ }
601+
602+ return (
603+ < Separator
604+ { ...props }
605+ ref = { ref }
606+ className = { mergeStyles (
607+ divider ( {
608+ size : 'M' ,
609+ orientation : 'horizontal' ,
610+ isStaticColor : false
611+ } ) ,
612+ style ( {
613+ gridColumnStart : 2 ,
614+ gridColumnEnd : - 2 ,
615+ marginY : size ( 5 ) // height of the menu separator is 12px, and the divider is 2px
616+ } )
617+ ) }
618+ />
619+ ) ;
620+ }
621+ ) ;
611622
612623export interface MenuSectionProps < T > extends Omit <
613624 AriaMenuSectionProps < T > ,
0 commit comments