Skip to content

fix: update default value handling for dynamic defaults #17609

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: format
  • Loading branch information
jaaydenh committed May 2, 2025
commit e95f0106f92c1e78bd10e994fdc13d69baf51b59
26 changes: 10 additions & 16 deletions site/src/modules/workspaces/DynamicParameter/DynamicParameter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
TooltipTrigger,
} from "components/Tooltip/Tooltip";
import { Info, Settings, TriangleAlert } from "lucide-react";
import { type FC, useId, useState, useEffect } from "react";
import { type FC, useEffect, useId, useState } from "react";
import type { AutofillBuildParameter } from "utils/richParameters";
import * as Yup from "yup";

Expand Down Expand Up @@ -205,16 +205,14 @@ const ParameterField: FC<ParameterFieldProps> = ({
disable: false,
}));

const selectedOptions: Option[] = JSON.parse(value).map(
(val: string) => {
const option = parameter.options.find((o) => o.value.value === val);
return {
value: val,
label: option?.name || val,
disable: false,
};
},
);
const selectedOptions: Option[] = JSON.parse(value).map((val: string) => {
const option = parameter.options.find((o) => o.value.value === val);
return {
value: val,
label: option?.name || val,
disable: false,
};
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is screaming for some sort of typing issue here. how confident are we that JSON.parse(value) will actually always return a string[] here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved


return (
<MultiSelectCombobox
Expand Down Expand Up @@ -255,11 +253,7 @@ const ParameterField: FC<ParameterFieldProps> = ({

case "radio":
return (
<RadioGroup
onValueChange={onChange}
disabled={disabled}
value={value}
>
<RadioGroup onValueChange={onChange} disabled={disabled} value={value}>
{parameter.options.map((option) => (
<div
key={option.value.value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const CreateWorkspacePageViewExperimental: FC<
parameter: PreviewParameter,
value: string,
) => {
const formInputs: {[k:string]:string} = {};
const formInputs: { [k: string]: string } = {};
formInputs[parameter.name] = value;

sendMessage(formInputs);
Expand Down