@@ -183,6 +183,9 @@ type MenuItemBaseProps = ForwardedFSClassProps &
183183 /** A description text to show under the title */
184184 description ?: string ;
185185
186+ /** Optional component to render before the description text (e.g. a badge pill) */
187+ descriptionAddon ?: ReactNode ;
188+
186189 /** Text to show below menu item. This text is not interactive */
187190 helperText ?: string ;
188191
@@ -507,6 +510,7 @@ function MenuItem({
507510 furtherDetailsStyle,
508511 furtherDetailsComponent,
509512 description,
513+ descriptionAddon,
510514 helperText,
511515 helperTextStyle,
512516 errorText,
@@ -645,13 +649,41 @@ function MenuItem({
645649
646650 const descriptionTextStyles = StyleUtils . combineStyles < TextStyle > ( [
647651 styles . textLabelSupporting ,
648- icon && ! Array . isArray ( icon ) ? styles . ml3 : { } ,
649- title ? descriptionVerticalMargin : StyleUtils . getFontSizeStyle ( variables . fontSizeNormal ) ,
652+ styles . flex1 ,
653+ title ? { } : StyleUtils . getFontSizeStyle ( variables . fontSizeNormal ) ,
650654 title ? styles . textLineHeightNormal : StyleUtils . getLineHeightStyle ( variables . fontSizeNormalHeight ) ,
655+ ! descriptionAddon && icon && ! Array . isArray ( icon ) ? styles . ml3 : { } ,
656+ descriptionAddon ? styles . ml2 : { } ,
651657 ( descriptionTextStyle as TextStyle ) || styles . breakWord ,
652658 isDeleted ? styles . offlineFeedbackDeleted : { } ,
653659 ] ) ;
654660
661+ const descriptionContainerStyle = StyleUtils . combineStyles < ViewStyle > ( [
662+ styles . flexRow ,
663+ styles . alignItemsCenter ,
664+ descriptionAddon && icon && ! Array . isArray ( icon ) ? styles . ml3 : { } ,
665+ title ? descriptionVerticalMargin : { } ,
666+ ] ) ;
667+
668+ const renderDescriptionView = ( ) => {
669+ if ( ! description && ! descriptionAddon ) {
670+ return null ;
671+ }
672+ return (
673+ < View style = { descriptionContainerStyle } >
674+ { descriptionAddon }
675+ { ! ! description && (
676+ < Text
677+ style = { descriptionTextStyles }
678+ numberOfLines = { numberOfLinesDescription }
679+ >
680+ { description }
681+ </ Text >
682+ ) }
683+ </ View >
684+ ) ;
685+ } ;
686+
655687 const html = useMemo ( ( ) => {
656688 if ( ! title || ! shouldParseTitle ) {
657689 return '' ;
@@ -943,14 +975,7 @@ function MenuItem({
943975 titleContainerStyle ,
944976 ] }
945977 >
946- { ! ! description && shouldShowDescriptionOnTop && (
947- < Text
948- style = { descriptionTextStyles }
949- numberOfLines = { numberOfLinesDescription }
950- >
951- { description }
952- </ Text >
953- ) }
978+ { shouldShowDescriptionOnTop && renderDescriptionView ( ) }
954979 { ( ! ! title || ! ! shouldShowTitleIcon ) && (
955980 < View
956981 style = { [ styles . flexRow , styles . alignItemsCenter , styles . mw100 , titleWrapperStyle ] }
@@ -981,14 +1006,7 @@ function MenuItem({
9811006 ) }
9821007 </ View >
9831008 ) }
984- { ! ! description && ! shouldShowDescriptionOnTop && (
985- < Text
986- style = { descriptionTextStyles }
987- numberOfLines = { numberOfLinesDescription }
988- >
989- { description }
990- </ Text >
991- ) }
1009+ { ! shouldShowDescriptionOnTop && renderDescriptionView ( ) }
9921010 { ! ! furtherDetails && (
9931011 < View style = { [ styles . flexRow , styles . mt1 , styles . alignItemsCenter ] } >
9941012 { ! ! furtherDetailsIcon && (
0 commit comments