diff --git a/invokeai/frontend/web/src/features/parameters/components/Parameters/Core/ParamScheduler.tsx b/invokeai/frontend/web/src/features/parameters/components/Parameters/Core/ParamScheduler.tsx index 0a343d0742..1fed60fa74 100644 --- a/invokeai/frontend/web/src/features/parameters/components/Parameters/Core/ParamScheduler.tsx +++ b/invokeai/frontend/web/src/features/parameters/components/Parameters/Core/ParamScheduler.tsx @@ -24,14 +24,17 @@ const ParamScheduler = () => { const { t } = useTranslation(); useEffect(() => { - if (selectedSchedulers.length === 0) + if (selectedSchedulers.length === 0) { dispatch(setSelectedSchedulers([...SCHEDULER_ITEMS])); + } const schedulerFound = activeSchedulers.find( (activeSchedulers) => activeSchedulers.value === scheduler ); - if (!schedulerFound) + + if (!schedulerFound) { dispatch(setScheduler(activeSchedulers[0].value as Scheduler)); + } }, [dispatch, selectedSchedulers, scheduler, activeSchedulers]); const handleChange = useCallback( diff --git a/invokeai/frontend/web/src/features/ui/store/uiSlice.ts b/invokeai/frontend/web/src/features/ui/store/uiSlice.ts index 907d5a5295..4de6109b20 100644 --- a/invokeai/frontend/web/src/features/ui/store/uiSlice.ts +++ b/invokeai/frontend/web/src/features/ui/store/uiSlice.ts @@ -99,13 +99,20 @@ export const uiSlice = createSlice({ setSelectedSchedulers: (state, action: PayloadAction) => { const selectedSchedulerData: SelectItem[] = []; - if (action.payload.length === 0) action.payload = [SCHEDULERS[0].value]; + let selectedSchedulers = [...action.payload]; - action.payload.forEach((item) => { + if (selectedSchedulers.length === 0) { + selectedSchedulers = [SCHEDULERS[0].value]; + } + + selectedSchedulers.forEach((item) => { const schedulerData = SCHEDULERS.find( (scheduler) => scheduler.value === item ); - if (schedulerData) selectedSchedulerData.push(schedulerData); + + if (schedulerData) { + selectedSchedulerData.push(schedulerData); + } }); state.activeSchedulers = selectedSchedulerData;