refactor: update radio component to handle boolean values instead of numeric (#24956)

This commit is contained in:
17hz
2025-09-02 15:11:42 +08:00
committed by GitHub
parent d6b3df8f6f
commit 2ac8f8003f
5 changed files with 15 additions and 21 deletions

View File

@@ -103,12 +103,6 @@ const BaseField = ({
})
}, [values, show_on])
const booleanRadioValue = useMemo(() => {
if (value === null || value === undefined)
return undefined
return value ? 1 : 0
}, [value])
if (!show)
return null
@@ -215,11 +209,11 @@ const BaseField = ({
formSchema.type === FormTypeEnum.boolean && (
<Radio.Group
className='flex w-fit items-center'
value={booleanRadioValue}
onChange={val => field.handleChange(val === 1)}
value={value}
onChange={v => field.handleChange(v)}
>
<Radio value={1} className='!mr-1'>True</Radio>
<Radio value={0}>False</Radio>
<Radio value={true} className='!mr-1'>True</Radio>
<Radio value={false}>False</Radio>
</Radio.Group>
)
}