@@ -13,6 +13,7 @@ const propTypes = {
13
13
// redux form props
14
14
input : PropTypes . object . isRequired ,
15
15
meta : PropTypes . object . isRequired ,
16
+ autoFocus : PropTypes . bool ,
16
17
} ;
17
18
18
19
const defaultProps = {
@@ -22,23 +23,28 @@ const defaultProps = {
22
23
size : null ,
23
24
info : null ,
24
25
multiline : false ,
26
+ autoFocus : false ,
25
27
} ;
26
28
27
- function FormInput ( { label, placeholder, type, size, info, input, meta, multiline } ) {
29
+ function FormInput ( {
30
+ label, placeholder, type, size, info, input, meta, multiline, autoFocus,
31
+ } ) {
28
32
const labelClasses = cx ( 'form-control-label' , { active : meta . active } ) ;
29
33
30
34
const inputClasses = cx ( 'form-control' , {
31
35
'is-invalid' : meta . error ,
32
36
'form-control-sm' : size === 'sm' ,
33
37
} ) ;
34
38
39
+ /* eslint-disable jsx-a11y/no-autofocus */
35
40
return (
36
41
< Field meta = { meta } info = { info } >
37
- { label &&
42
+ { label && (
38
43
< label htmlFor = { `${ meta . form } -${ input . name } ` } className = { labelClasses } >
39
44
{ label }
40
- </ label > }
41
- { ! multiline &&
45
+ </ label >
46
+ ) }
47
+ { ! multiline && (
42
48
< input
43
49
type = { type }
44
50
id = { `${ meta . form } -${ input . name } ` }
@@ -51,8 +57,10 @@ function FormInput({ label, placeholder, type, size, info, input, meta, multilin
51
57
} }
52
58
placeholder = { placeholder }
53
59
className = { inputClasses }
54
- /> }
55
- { multiline &&
60
+ autoFocus = { autoFocus }
61
+ />
62
+ ) }
63
+ { multiline && (
56
64
< textarea
57
65
id = { `${ meta . form } -${ input . name } ` }
58
66
name = { input . name }
@@ -65,9 +73,12 @@ function FormInput({ label, placeholder, type, size, info, input, meta, multilin
65
73
placeholder = { placeholder }
66
74
rows = "7"
67
75
className = { inputClasses }
68
- /> }
76
+ autoFocus = { autoFocus }
77
+ />
78
+ ) }
69
79
</ Field >
70
80
) ;
81
+ /* eslint-enable */
71
82
}
72
83
73
84
FormInput . propTypes = propTypes ;
0 commit comments