@@ -18,26 +18,28 @@ const FormField = ({ field, isGroupField }) => {
18
18
< Field name = { field . name } >
19
19
{ ( { input, meta } ) => (
20
20
< div styleName = { isGroupField ? "field-group-field" : "" } >
21
- < label
22
- styleName = {
23
- input . value
24
- ? "job-field-label"
25
- : "job-field-label job-field-no-label"
26
- }
27
- >
28
- { field . label }
29
- </ label >
21
+ { ! field . readonly && (
22
+ < label
23
+ styleName = {
24
+ ( input . value != "undefined" && input . value !== null && input . value !== "" ) || meta . active
25
+ ? "job-field-label"
26
+ : "job-field-label job-field-no-label"
27
+ }
28
+ >
29
+ { field . label }
30
+ </ label >
31
+ ) }
30
32
{ field . type === FORM_FIELD_TYPE . TEXT && (
31
33
< TextInput
32
34
maxLength = { field . maxLength }
33
35
placeholder = { field . placeholder }
34
36
value = { input . value ?? "" }
35
37
type = "text"
36
- onChange = { ( v ) => {
37
- input . onChange ( v ) ;
38
- } }
39
- className = { meta . error ? "error" : "" }
38
+ className = { meta . error && meta . touched ? "error" : "" }
40
39
readonly = { field . readonly }
40
+ onChange = { input . onChange }
41
+ onBlur = { input . onBlur }
42
+ onFocus = { input . onFocus }
41
43
/>
42
44
) }
43
45
{ field . type === FORM_FIELD_TYPE . NUMBER && (
@@ -47,37 +49,41 @@ const FormField = ({ field, isGroupField }) => {
47
49
type = "number"
48
50
minValue = { field . minValue }
49
51
onChange = { input . onChange }
50
- className = { meta . error ? "error" : "" }
52
+ onBlur = { input . onBlur }
53
+ onFocus = { input . onFocus }
54
+ className = { meta . error && meta . touched ? "error" : "" }
51
55
/>
52
56
) }
53
57
{ field . type === FORM_FIELD_TYPE . TEXTAREA && (
54
58
< TextArea
55
59
placeholder = { field . placeholder }
56
60
value = { input ?. value ?? "" }
57
61
onChange = { input . onChange }
58
- className = { meta . error ? "error" : "" }
62
+ onBlur = { input . onBlur }
63
+ onFocus = { input . onFocus }
64
+ className = { meta . error && meta . touched ? "error" : "" }
59
65
/>
60
66
) }
61
67
{ field . type === FORM_FIELD_TYPE . DATE && (
62
68
< DateInput
63
69
placeholder = { field . placeholder }
64
70
value = { input ?. value ?? "" }
65
- onChange = { ( date ) => {
66
- input . onChange ( date ) ;
67
- } }
71
+ onChange = { input . onChange }
72
+ onBlur = { input . onBlur }
73
+ onFocus = { input . onFocus }
68
74
/>
69
75
) }
70
76
{ field . type === FORM_FIELD_TYPE . SELECT && (
71
77
< ReactSelect
72
78
value = { input ?. value ?? "" }
73
- onChange = { ( val ) => {
74
- input . onChange ( val ) ;
75
- } }
76
79
options = { field . selectOptions }
77
80
isMulti = { field . isMulti }
81
+ onChange = { input . onChange }
82
+ onBlur = { input . onBlur }
83
+ onFocus = { input . onFocus }
78
84
/>
79
85
) }
80
- { field . isRequired && meta . error && (
86
+ { field . isRequired && meta . error && meta . touched && (
81
87
< div styleName = "field-error" > { meta . error } </ div >
82
88
) }
83
89
</ div >
0 commit comments