fix: preserve parameter values when dynamic ordering changes #18270
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When creating a workspace from a template with dynamic parameter ordering, parameter values are not displaying correctly when the order changes. This occurs when a parameter's
order
value depends on another parameter's value.Example scenario:
When the user toggles
reorder
fromfalse
totrue
, thecpu
parameter moves from position 2 to position 0, but its value gets mixed up with thereorder
parameter's value.Root Cause
The issue was in
CreateWorkspacePageViewExperimental.tsx
where parameters were rendered using array indices instead of parameter names:When parameters are reordered:
parameters
array order changes based on the neworder
valuesform.values.rich_parameter_values
array maintains the original orderSolution
Implemented name-based lookup to ensure parameter values stay with their correct parameters:
Testing
Impact
This fix ensures that users can reliably use dynamic parameter ordering in their templates without losing parameter values when the order changes. This is particularly important for templates that use conditional parameter visibility and ordering based on user selections.