From 2b5d81d6605940747a5321d46f19768fef78142f Mon Sep 17 00:00:00 2001 From: Rankin Zheng Date: Fri, 15 Dec 2023 07:27:08 +0800 Subject: [PATCH] fix radio group no user's value --- src/views/components/ChatMark/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/views/components/ChatMark/index.tsx b/src/views/components/ChatMark/index.tsx index 7a00d7e..688e12b 100644 --- a/src/views/components/ChatMark/index.tsx +++ b/src/views/components/ChatMark/index.tsx @@ -199,7 +199,6 @@ const ChatMark = ({ children,value,messageDone }) => { }); } },[]); - // Render markdown widgets const renderWidgets = (widgets) => { let radioGroupTemp:any = []; @@ -239,8 +238,11 @@ const ChatMark = ({ children,value,messageDone }) => { // if next widget is not radio, then end current group const nextWidget = index + 1 < widgets.length? widgets[index + 1]:null; if (!nextWidget || nextWidget.type !== 'radio') { - const radioGroup = ((radios,allValues)=>{ + const filteredValues = allValues.filter((value) => values[value] === 'checked'); + return 0 ? filteredValues[0] : undefined} onChange={ event => handleRadioChange({ event, @@ -248,7 +250,8 @@ const ChatMark = ({ children,value,messageDone }) => { }) }> {radios} - )(radioGroupTemp,radioValuesTemp); + ; + })(radioGroupTemp,radioValuesTemp); radioGroupTemp = []; radioValuesTemp = []; wdigetsTemp.push(radioGroup);