fix radio group no user's value

This commit is contained in:
Rankin Zheng 2023-12-15 07:27:08 +08:00
parent 42ae7b0cc1
commit 2b5d81d660

View File

@ -199,7 +199,6 @@ const ChatMark = ({ children,value,messageDone }) => {
}); });
} }
},[]); },[]);
// Render markdown widgets // Render markdown widgets
const renderWidgets = (widgets) => { const renderWidgets = (widgets) => {
let radioGroupTemp:any = []; let radioGroupTemp:any = [];
@ -239,8 +238,11 @@ const ChatMark = ({ children,value,messageDone }) => {
// if next widget is not radio, then end current group // if next widget is not radio, then end current group
const nextWidget = index + 1 < widgets.length? widgets[index + 1]:null; const nextWidget = index + 1 < widgets.length? widgets[index + 1]:null;
if (!nextWidget || nextWidget.type !== 'radio') { if (!nextWidget || nextWidget.type !== 'radio') {
const radioGroup = ((radios,allValues)=><Radio.Group const radioGroup = ((radios,allValues)=>{
const filteredValues = allValues.filter((value) => values[value] === 'checked');
return <Radio.Group
key={`radio-group-${index}`} key={`radio-group-${index}`}
value={filteredValues.length > 0 ? filteredValues[0] : undefined}
onChange={ onChange={
event => handleRadioChange({ event => handleRadioChange({
event, event,
@ -248,7 +250,8 @@ const ChatMark = ({ children,value,messageDone }) => {
}) })
}> }>
{radios} {radios}
</Radio.Group>)(radioGroupTemp,radioValuesTemp); </Radio.Group>;
})(radioGroupTemp,radioValuesTemp);
radioGroupTemp = []; radioGroupTemp = [];
radioValuesTemp = []; radioValuesTemp = [];
wdigetsTemp.push(radioGroup); wdigetsTemp.push(radioGroup);