fix: update multi-select to use value prop for dynamic defaults #18982
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.
contributes to coder/internal#753
Summary
Fixes issue where multi-select parameters don't update their selected values when dynamic defaults change.
Changes
MultiSelectCombobox
inDynamicParameter
to usevalue
prop instead ofdefaultOptions
Problem
When using dynamic parameters with multi-select form types, changing one parameter (like
git_repo
) that affects the defaults of another multi-select parameter (likeides
) would not update the selected values in the UI. The form state would update correctly, but the UI would show stale selected options.Root Cause
The
MultiSelectCombobox
component was usingdefaultOptions
prop which only sets initial state. When the parent component updates the selected options due to dynamic parameter changes, the component wasn't reacting to these changes.Solution
Using the
value
prop instead ofdefaultOptions
makes the component controlled and reactive to parent state changes. TheMultiSelectCombobox
already has logic to handle value updates:Testing
This change maintains the same API and behavior for static parameters while fixing the dynamic update issue. The component will now properly update selected values when the parent provides new values.
Fixes coder/internal#753