@@ -484,13 +484,19 @@ impl LayoutGroup {
484484 }
485485}
486486
487- #[ derive( Debug , Clone , PartialEq , serde:: Serialize , serde:: Deserialize , specta:: Type ) ]
487+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , specta:: Type ) ]
488488pub struct WidgetHolder {
489489 #[ serde( rename = "widgetId" ) ]
490490 pub widget_id : WidgetId ,
491491 pub widget : Widget ,
492492}
493493
494+ impl PartialEq for WidgetHolder {
495+ fn eq ( & self , other : & Self ) -> bool {
496+ self . widget == other. widget
497+ }
498+ }
499+
494500impl WidgetHolder {
495501 #[ deprecated( since = "0.0.0" , note = "Please use the builder pattern, e.g. TextLabel::new(\" hello\" ).widget_holder()" ) ]
496502 pub fn new ( widget : Widget ) -> Self {
@@ -502,6 +508,26 @@ impl WidgetHolder {
502508
503509 /// Diffing updates self (where self is old) based on new, updating the list of modifications as it does so.
504510 pub fn diff ( & mut self , new : Self , widget_path : & mut [ usize ] , widget_diffs : & mut Vec < WidgetDiff > ) {
511+ if let ( Widget :: PopoverButton ( button1) , Widget :: PopoverButton ( button2) ) = ( & mut self . widget , & new. widget ) {
512+ if button1. disabled == button2. disabled
513+ && button1. style == button2. style
514+ && button1. menu_direction == button2. menu_direction
515+ && button1. icon == button2. icon
516+ && button1. tooltip == button2. tooltip
517+ && button1. tooltip_shortcut == button2. tooltip_shortcut
518+ && button1. popover_min_width == button2. popover_min_width
519+ {
520+ let mut new_widget_path = widget_path. to_vec ( ) ;
521+ for ( i, ( a, b) ) in button1. popover_layout . iter_mut ( ) . zip ( button2. popover_layout . iter ( ) ) . enumerate ( ) {
522+ new_widget_path. push ( i) ;
523+ a. diff ( b. clone ( ) , & mut new_widget_path, widget_diffs) ;
524+ new_widget_path. pop ( ) ;
525+ }
526+ self . widget = new. widget ;
527+ return ;
528+ }
529+ }
530+
505531 // If there have been changes to the actual widget (not just the id)
506532 if self . widget != new. widget {
507533 // We should update to the new widget value as well as a new widget id
0 commit comments