File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,13 @@ const FormLabel: FormLabel = React.forwardRef(
107
107
108
108
if ( column )
109
109
return (
110
- < Col as = "label" className = { classes } htmlFor = { htmlFor } { ...props } />
110
+ < Col
111
+ ref = { ref as React . ForwardedRef < HTMLLabelElement > }
112
+ as = "label"
113
+ className = { classes }
114
+ htmlFor = { htmlFor }
115
+ { ...props }
116
+ />
111
117
) ;
112
118
113
119
return (
Original file line number Diff line number Diff line change @@ -71,6 +71,27 @@ describe('<FormLabel>', () => {
71
71
expect ( instance . input . tagName ) . to . equal ( 'LABEL' ) ;
72
72
} ) ;
73
73
74
+ it ( 'should support ref forwarding when rendered as a Col' , ( ) => {
75
+ class Container extends React . Component {
76
+ render ( ) {
77
+ return (
78
+ < FormGroup controlId = "foo" >
79
+ < FormLabel
80
+ type = "text"
81
+ column
82
+ ref = { ( ref ) => {
83
+ this . input = ref ;
84
+ } }
85
+ />
86
+ </ FormGroup >
87
+ ) ;
88
+ }
89
+ }
90
+
91
+ const instance = mount ( < Container /> ) . instance ( ) ;
92
+ expect ( instance . input . tagName ) . to . equal ( 'LABEL' ) ;
93
+ } ) ;
94
+
74
95
it ( 'accepts as prop' , ( ) => {
75
96
mount ( < FormLabel as = "legend" > body</ FormLabel > ) . assertSingle ( 'legend' ) ;
76
97
} ) ;
You can’t perform that action at this time.
0 commit comments