- Notifications
You must be signed in to change notification settings - Fork905
fix: preserve parameter values when dynamic ordering changes#18270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
blink-so wants to merge2 commits intomainChoose a base branch fromfix/dynamic-parameter-ordering-values
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
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.
Emyrk approved these changesJun 6, 2025
Comment on lines +611 to +619
const currentParameterValueIndex = | ||
form.values.rich_parameter_values?.findIndex( | ||
(p) => p.name === parameter.name, | ||
) ?? -1; | ||
const parameterFieldIndex = | ||
currentParameterValueIndex !== -1 | ||
? currentParameterValueIndex | ||
: index; | ||
const parameterField = `rich_parameter_values.${parameterFieldIndex}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@jaaydenh The overall approach looks correct to me. There might be some cleaner simplier syntax
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
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.