@@ -23,21 +23,27 @@ type SelectFieldProps = {
2323 inputValue ?: string ,
2424 /** callback to control search value */
2525 onInputChange ?: ( value : string , event ?: SyntheticInputEvent < HTMLInputElement > ) => void ,
26+ /** show error only for touched fields */
27+ showErrorOnTouched ?: boolean ,
2628} ;
2729
2830class SelectField extends React . Component < SelectFieldProps > {
31+ static defaultProps = {
32+ showErrorOnTouched : true ,
33+ } ;
34+
2935 collectFormFieldProps ( ) {
30- const { meta, input, stretch, label } = this . props ;
36+ const { meta, input, stretch, label, showErrorOnTouched } = this . props ;
3137
32- return { meta, input, stretch, label } ;
38+ return { meta , input , stretch , label , showErrorOnTouched } ;
3339 }
3440
3541 collectSelectProps ( ) {
3642 const {
37- input = { } , meta, placeholder, options, multiple, isMulti, creatable, stretch, filterOption, getOptionValue, getOptionLabel,
43+ input = { } , meta, placeholder, options, multiple, isMulti, creatable, stretch, filterOption, getOptionValue, getOptionLabel, showErrorOnTouched ,
3844 } = this . props ;
3945
40- const hasError = formUtils . hasError ( meta ) ;
46+ const hasError = formUtils . hasError ( meta , showErrorOnTouched ) ;
4147
4248 return {
4349 ...this . props ,
0 commit comments