@@ -24,8 +24,8 @@ use crate::styles::components::{
2424} ;
2525use crate :: styles:: Styles ;
2626use crate :: widget:: {
27- Callback , EventHandling , MakeWidget , MakeWidgetWithTag , SharedNotify , Widget , WidgetId ,
28- WidgetInstance , WidgetLayout , WidgetRef , WidgetTag , HANDLED ,
27+ Baseline , Callback , EventHandling , MakeWidget , MakeWidgetWithTag , SharedNotify , Widget ,
28+ WidgetId , WidgetInstance , WidgetLayout , WidgetRef , WidgetTag , HANDLED ,
2929} ;
3030use crate :: ConstraintLimit ;
3131
@@ -664,20 +664,21 @@ where
664664 let available_width = available_space. width . max ( ) - double_padding;
665665
666666 let mut y = self . padding ;
667- for rendered in & mut self . items {
667+ let mut first_baseline = Baseline :: NONE ;
668+ for ( index, rendered) in self . items . iter_mut ( ) . enumerate ( ) {
668669 let ( height, full_height) = match & mut rendered. item {
669670 ItemKind :: Item ( item) => {
670671 let mounted = item. contents . mounted ( context) ;
671672 let available_width = available_width - submenu_space;
672- let size = context
673- . for_other ( & mounted )
674- . layout ( Size :: new (
675- ConstraintLimit :: SizeToFit ( available_width ) ,
676- ConstraintLimit :: SizeToFit ( remaining_height ) ,
677- ) )
678- . size ;
679- maximum_item_width = maximum_item_width . max ( size . width ) ;
680- ( size. height , size. height + double_padding)
673+ let layout = context. for_other ( & mounted ) . layout ( Size :: new (
674+ ConstraintLimit :: SizeToFit ( available_width ) ,
675+ ConstraintLimit :: SizeToFit ( remaining_height ) ,
676+ ) ) ;
677+ maximum_item_width = maximum_item_width . max ( layout . size . width ) ;
678+ if index == 0 {
679+ first_baseline = layout . baseline ;
680+ }
681+ ( layout . size . height , layout . size . height + double_padding)
681682 }
682683 ItemKind :: Separator => ( UPx :: ZERO , self . padding ) ,
683684 } ;
@@ -704,8 +705,10 @@ where
704705 ) ;
705706 }
706707
707- // TODO should a Menu report its baseline?
708- Size :: new ( maximum_item_width + double_padding * 2 + submenu_space, y) . into ( )
708+ WidgetLayout {
709+ size : Size :: new ( maximum_item_width + double_padding * 2 + submenu_space, y) ,
710+ baseline : first_baseline,
711+ }
709712 }
710713
711714 fn hit_test (
0 commit comments