diff --git a/src/features/run/EditConfigsDialog.tsx b/src/features/run/EditConfigsDialog.tsx index 50334226ba..a4455ecb83 100644 --- a/src/features/run/EditConfigsDialog.tsx +++ b/src/features/run/EditConfigsDialog.tsx @@ -230,8 +230,20 @@ function EditConfigsDialog() { } return out; }, [draft, formErrorsById, types]); - const invalid = Object.keys(errorsById).length > 0; + // Only configurations added or changed here keep the dialog from saving: one that was already + // invalid when it opened (an older temporary, a project file) doesn't block the others. + const [opened] = useState(() => new Map(initialConfigs.map((c) => [c.id, JSON.stringify(c)]))); + const [savedUnedited] = useState(() => (useRun.getState().editDirty ? target : null)); + const blocking = useMemo( + () => + draft + .filter((c) => errorsById[c.id] && (c.id === savedUnedited || opened.get(c.id) !== JSON.stringify(c))) + .map((c) => c.id), + [draft, errorsById, opened, savedUnedited], + ); + const invalid = blocking.length > 0; const errors = (current && errorsById[current.id]) ?? {}; + const cannotLaunch = invalid || (!!current && !!errorsById[current.id]); const currentType = current ? typeForConfig(current, types) : undefined; const currentTemplateType = currentTemplate ? typeFor(currentTemplate.kind) : undefined; @@ -323,7 +335,7 @@ function EditConfigsDialog() { const save = async (andClose: boolean): Promise => { if (invalid) { - const firstBad = Object.keys(errorsById)[0]; + const firstBad = blocking[0]; if (firstBad) { setMode("configs"); setSelection({ type: "config", id: firstBad }); @@ -414,14 +426,14 @@ function EditConfigsDialog() {