Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit290f11b

Browse files
committed
fix: preserve parameter values when dynamic ordering changes
When parameters are reordered dynamically (e.g., when a parameter's orderdepends on another parameter's value), the parameter values were notdisplaying correctly. This was because the rendering logic used arrayindices instead of parameter names to map form values.The issue occurred when:1. Parameters are initially rendered in one order2. A parameter value changes, causing dynamic reordering3. The parameter array order changes but form values array stays the same4. Values get mismatched due to index-based lookupThis fix implements name-based lookup to ensure parameter values persistcorrectly regardless of ordering changes:- Find parameter value by name instead of array index- Use the found index for form field mapping- Fallback to current index for new parametersFixes parameter value persistence in dynamic parameter ordering scenarios.
1 parent348d19d commit290f11b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

‎site/src/pages/CreateWorkspacePage/CreateWorkspacePageViewExperimental.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,15 @@ export const CreateWorkspacePageViewExperimental: FC<
608608

609609
<divclassName="flex flex-col gap-9">
610610
{parameters.map((parameter,index)=>{
611-
constparameterField=`rich_parameter_values.${index}`;
611+
// Find the current parameter's value by name instead of index
612+
// to ensure values persist correctly when parameter order changes
613+
constcurrentParameterValueIndex=form.values.rich_parameter_values?.findIndex(
614+
(p)=>p.name===parameter.name
615+
)??-1;
616+
617+
// Use the found index for the parameter field, or fallback to current index
618+
constparameterFieldIndex=currentParameterValueIndex!==-1 ?currentParameterValueIndex :index;
619+
constparameterField=`rich_parameter_values.${parameterFieldIndex}`;
612620
constisPresetParameter=presetParameterNames.includes(
613621
parameter.name,
614622
);
@@ -629,8 +637,10 @@ export const CreateWorkspacePageViewExperimental: FC<
629637
returnnull;
630638
}
631639

632-
constformValue=
633-
form.values?.rich_parameter_values?.[index]?.value||"";
640+
// Get the form value by parameter name to ensure correct value mapping
641+
constformValue=currentParameterValueIndex!==-1
642+
?form.values?.rich_parameter_values?.[currentParameterValueIndex]?.value||""
643+
:"";
634644

635645
return(
636646
<DynamicParameter

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp