@@ -870,27 +870,22 @@ def display_TOPP_params(params: dict, num_cols):
870870 # Filter current values to only include valid options
871871 current_values = [v for v in p ["value" ] if v in p ['valid_strings' ]]
872872
873- # Create a temporary key for multiselect, then convert to newline string
874- multiselect_key = f"{ key } _multiselect "
873+ # Use a display key for multiselect (stores list), sync to main key (stores string)
874+ display_key = f"{ key } _display "
875875
876- # Initialize multiselect key from the main key if needed
877- if multiselect_key not in st .session_state :
878- st .session_state [multiselect_key ] = current_values
879-
880- # Define callback to sync multiselect list to newline-separated string
881- def sync_multiselect_to_string (ms_key = multiselect_key , target_key = key ):
882- st .session_state [target_key ] = "\n " .join (st .session_state [ms_key ])
876+ def on_multiselect_change (dk = display_key , tk = key ):
877+ st .session_state [tk ] = "\n " .join (st .session_state [dk ])
883878
884879 cols [i ].multiselect (
885880 name ,
886881 options = sorted (p ['valid_strings' ]),
887- default = None , # Use session state
882+ default = current_values ,
888883 help = p ["description" ],
889- key = multiselect_key ,
890- on_change = sync_multiselect_to_string ,
884+ key = display_key ,
885+ on_change = on_multiselect_change ,
891886 )
892887
893- # Initialize the string key if not present
888+ # Ensure main key has string value for ParameterManager
894889 if key not in st .session_state :
895890 st .session_state [key ] = "\n " .join (current_values )
896891 else :
0 commit comments