From f04e814c6e6a06c037bc8e356e72f69e8b31449a Mon Sep 17 00:00:00 2001 From: "DESKTOP-E41MSIT\\saneesh" <124969366+saneesh-aot@users.noreply.github.com> Date: Tue, 15 Oct 2024 03:57:48 -0700 Subject: [PATCH] Radio button change defaultChecked index value --- .../src/components/CustomComponents/Radio.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/forms-flow-components/src/components/CustomComponents/Radio.tsx b/forms-flow-components/src/components/CustomComponents/Radio.tsx index d03bb63f..20c42a17 100644 --- a/forms-flow-components/src/components/CustomComponents/Radio.tsx +++ b/forms-flow-components/src/components/CustomComponents/Radio.tsx @@ -1,24 +1,28 @@ import React from "react"; import Form from "react-bootstrap/Form"; + interface RadioOption { label: string; onClick: () => void; } - + interface CustomRadioButtonProps { items: RadioOption[]; dataTestid?: string; ariaLabel?: string; + indexValue?: number; } + export const CustomRadioButton: React.FC = ({ items, dataTestid = "", ariaLabel = "", + indexValue = 0, }) => { return ( -
+ {items.map((option, index) => ( = ({ id={`inline-radio-${index + 1}`} data-testid={`${dataTestid}-inline-radio-${index + 1}`} key={`radio-${index + 1}`} - defaultChecked={index === 0} + defaultChecked={index === indexValue} onClick={option.onClick} + /> ))} ); }; + + + +