Skip to content

Commit ecdd93b

Browse files
nowgnuesLeeironAiken2
authored andcommitted
fix(FR-2773): preserve auto-selected resourcePresetId across applyInitialValues
The Resource Preset row showed '-' on the deployment launcher review step even though the user had a preset selected on step 3. Root cause: `applyInitialValues` runs after ResourcePresetSelect's child `autoSelectDefault` effect on mount, and `setFieldsValue` was writing `resourcePresetId: undefined` from `merged`, clobbering the value the child had already auto-selected. ResourcePresetSelect uses `useControllableState_deprecated` whose `stateRef` retains the auto-selected value when the antd-injected `value` is undefined, so the step-3 Select still displayed the preset name (giving the user the impression it was selected) while `form.getFieldsValue()` returned undefined — and the review summary's `values.resourcePresetId ? ... : '-'` fell to the dash branch. The existing code already handled this race for `resourceGroup` via `_.omit(merged, 'resourceGroup')`. Generalize that omit list to also cover `resourcePresetId` so any field whose child component owns autoSelect is left alone when the merged value is empty.
1 parent b6d3266 commit ecdd93b

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

react/src/components/DeploymentLauncherPageContent.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,25 @@ const DeploymentLauncherPageContent: React.FC<
496496
? _.merge({}, initialValues, formValuesFromURL)
497497
: initialValues;
498498

499-
// In create mode, skip setting an empty resourceGroup so that
500-
// BAIProjectResourceGroupSelect.autoSelectDefault can pick the first option.
501-
// Child effects (auto-select) run before parent effects (this one), so
502-
// passing '' here would override the already-selected value.
499+
// In create mode, skip setting empty fields whose child component owns an
500+
// autoSelectDefault flow. Child effects (auto-select) run before parent
501+
// effects (this one), so passing an empty value here would clobber the
502+
// value the child has already selected — the child's internal display
503+
// state would survive but the form value reads as undefined, so downstream
504+
// readers (e.g. the review summary) see '-'.
505+
//
506+
// Membership rule: add a field here only if its step-2/3 Select passes
507+
// `autoSelectDefault`. Currently: BAIProjectResourceGroupSelect (step 3)
508+
// and ResourcePresetSelect (step 3). VFolderSelect (step 2) does not pass
509+
// autoSelectDefault; if that ever changes, add 'modelFolderId' here.
510+
const autoSelectKeys: Array<keyof DeploymentLauncherFormValue> = [
511+
'resourceGroup',
512+
'resourcePresetId',
513+
];
514+
const omitKeys =
515+
mode === 'create' ? autoSelectKeys.filter((k) => !merged[k]) : [];
503516
form.setFieldsValue(
504-
mode === 'create' && !merged.resourceGroup
505-
? _.omit(merged, 'resourceGroup')
506-
: merged,
517+
omitKeys.length > 0 ? _.omit(merged, omitKeys) : merged,
507518
);
508519
});
509520

0 commit comments

Comments
 (0)