Skip to content

Commit

Permalink
fix: boolean field
Browse files Browse the repository at this point in the history
  • Loading branch information
tien committed Mar 3, 2025
1 parent 6edc721 commit 9f7ae19
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/components/param/primitive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function PrimitiveParam({

switch (primitive.codec) {
case "bool":
return Boolean(value);
return Boolean(JSON.parse(value));
case "char":
return value.length === 1 ? value : INVALID;
case "u8":
Expand Down Expand Up @@ -142,12 +142,10 @@ export function PrimitiveParam({
switch (primitive.codec) {
case "bool":
return (
<Field.Input asChild>
<Switch
checked={Boolean(value)}
onCheckedChange={(event) => setValue(String(event.checked))}
/>
</Field.Input>
<Switch
checked={Boolean(JSON.parse(value))}
onCheckedChange={(event) => setValue(JSON.stringify(event.checked))}
/>
);
case "char":
return <Field.Input {...commonProps} maxLength={1} />;
Expand Down

0 comments on commit 9f7ae19

Please sign in to comment.