@@ -27,7 +27,7 @@ import Radio from '../../addons/Radio'
27
27
* @see Radio
28
28
* @see Select
29
29
*/
30
- function FormField ( props ) {
30
+ const FormField = React . forwardRef ( function ( props , ref ) {
31
31
const {
32
32
children,
33
33
className,
@@ -77,14 +77,14 @@ function FormField(props) {
77
77
if ( _ . isNil ( control ) ) {
78
78
if ( _ . isNil ( label ) ) {
79
79
return (
80
- < ElementType { ...rest } className = { classes } id = { id } >
80
+ < ElementType { ...rest } className = { classes } id = { id } ref = { ref } >
81
81
{ childrenUtils . isNil ( children ) ? content : children }
82
82
</ ElementType >
83
83
)
84
84
}
85
85
86
86
return (
87
- < ElementType { ...rest } className = { classes } id = { id } >
87
+ < ElementType { ...rest } className = { classes } id = { id } ref = { ref } >
88
88
{ errorLabelBefore }
89
89
{ createHTMLLabel ( label , { autoGenerateKey : false } ) }
90
90
{ errorLabelAfter }
@@ -101,7 +101,7 @@ function FormField(props) {
101
101
'aria-describedby' : ariaDescribedBy ,
102
102
'aria-invalid' : error ? true : undefined ,
103
103
}
104
- const controlProps = { ...rest , content, children, disabled, required, type, id }
104
+ const controlProps = { ...rest , content, children, disabled, required, type, id, ref }
105
105
106
106
// wrap HTML checkboxes/radios in the label
107
107
if ( control === 'input' && ( type === 'checkbox' || type === 'radio' ) ) {
@@ -142,7 +142,9 @@ function FormField(props) {
142
142
{ errorLabelAfter }
143
143
</ ElementType >
144
144
)
145
- }
145
+ } )
146
+
147
+ FormField . displayName = 'FormField'
146
148
147
149
FormField . propTypes = {
148
150
/** An element type to render as (string or function). */
0 commit comments