Selection of multiselect widget is reset after updating options

Unfortunately that doesn’t solve it either.
The problem also occurs when I change the widget’s options by simply overriding the st.session_state.name_filter_options instead of removing items from it.

It’s the same in this code from Shawn_Pereira: Update options of multiselect widget
If a function is selected and then a function is added, the previous selection is reset even if the function still exists as option.

Could it be that whenever the options were changed from the outside, it creates a whole new widget, which of course resets the widget’s selection? If so, is there a way to keep the selection?