From 04a0cacd56405827bf0626c94a4a7d53199ac521 Mon Sep 17 00:00:00 2001 From: Joseph Mathew Date: Fri, 6 Jun 2025 21:21:26 +0530 Subject: [PATCH] Added ref support in Radio.Item --- src/components/Radio/Item.jsx | 67 +++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/src/components/Radio/Item.jsx b/src/components/Radio/Item.jsx index 95426be1b..2d2f4538b 100644 --- a/src/components/Radio/Item.jsx +++ b/src/components/Radio/Item.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { forwardRef } from "react"; import classnames from "classnames"; import PropTypes from "prop-types"; @@ -7,37 +7,42 @@ import Label from "components/Label"; import { useId } from "hooks"; import { hyphenize } from "utils"; -const Item = ({ - name = "", - label = "", - className = "", - labelProps, - dataCy = "", - ...otherProps -}) => { - const id = useId(otherProps.id); +const Item = forwardRef( + ( + { + name = "", + label = "", + className = "", + labelProps, + dataCy = "", + ...otherProps + }, + ref + ) => { + const id = useId(otherProps.id); - return ( -
- - {label && ( - - )} -
- ); -}; + return ( +
+ + {label && ( + + )} +
+ ); + } +); Item.displayName = "Radio.Item";