@@ -5,6 +5,7 @@ use graphene_std::raster::color::Color;
55use graphene_std:: text:: Font ;
66use graphene_std:: vector:: style:: { FillChoice , GradientStops } ;
77use serde_json:: Value ;
8+ use std:: collections:: HashMap ;
89
910#[ derive( ExtractField ) ]
1011pub struct LayoutMessageContext < ' a > {
@@ -470,10 +471,18 @@ impl LayoutMessageHandler {
470471 fn diff_and_send_layout_to_frontend (
471472 & mut self ,
472473 layout_target : LayoutTarget ,
473- new_layout : Layout ,
474+ mut new_layout : Layout ,
474475 responses : & mut VecDeque < Message > ,
475476 action_input_mapping : & impl Fn ( & MessageDiscriminant ) -> Option < KeysGroup > ,
476477 ) {
478+ // Step 1: Collect CheckboxId mappings from new layout
479+ let mut checkbox_map = HashMap :: new ( ) ;
480+ new_layout. collect_checkbox_ids ( layout_target, & mut Vec :: new ( ) , & mut checkbox_map) ;
481+
482+ // Step 2: Replace all IDs in new layout with deterministic ones
483+ new_layout. replace_widget_ids ( layout_target, & mut Vec :: new ( ) , & checkbox_map) ;
484+
485+ // Step 3: Diff with deterministic IDs
477486 let mut widget_diffs = Vec :: new ( ) ;
478487
479488 self . layouts [ layout_target as usize ] . diff ( new_layout, & mut Vec :: new ( ) , & mut widget_diffs) ;
0 commit comments