Frontend error if visibility of MultipleSelectField is toggled False

When a MultipleSelectField has options selected and the visibility is toggled False with a ToggleButton, the frontend will color the label of Section and Tab red. Is there a workaround for this?
Before untoggle:

After untoggle:

The options are probably filled dynamically depending on the toggle?

You could do something along these lines:

def options(params, **kwargs):
    if params.toggle:
        options = [...]  # api call to GEF files
    return params.selected_gef_files  # keep options which are currently selected

Thanks @khameeteman. This works, but i am not sure why yet :crazy_face:
I was returning a list with one OptionListElement, with a default value. This conflicts with the already saved selected options in the saved params.

for future reference, i changed this:

def _get_gefs(params: Munch, **kwargs) -> List[OptionListElement]:
    if not params.user_input.general.use_subset_cpts:
        return [OptionListElement(WARNING_MESSAGE)]

    gef_options = ['get gef options through api call']

    if not gef_options:
        return [OptionListElement(WARNING_MESSAGE)]
    return gef_options

in this:

def _get_gefs(params: Munch, **kwargs) -> List[OptionListElement]:
    if not params.user_input.general.use_subset_cpts:
        return params.user_input.general.cpts
    
    gef_options = ['get gef options through api call']

    if not gef_options:
        return [OptionListElement(WARNING_MESSAGE)]
    return gef_options