File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 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(
107107
108108 if ( column )
109109 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+ />
111117 ) ;
112118
113119 return (
Original file line number Diff line number Diff line change @@ -71,6 +71,27 @@ describe('<FormLabel>', () => {
7171 expect ( instance . input . tagName ) . to . equal ( 'LABEL' ) ;
7272 } ) ;
7373
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+
7495 it ( 'accepts as prop' , ( ) => {
7596 mount ( < FormLabel as = "legend" > body</ FormLabel > ) . assertSingle ( 'legend' ) ;
7697 } ) ;
You can’t perform that action at this time.
0 commit comments