Browse Source

autocomple small fix

amenpunk 3 years ago
parent
commit
176a5459a3
1 changed files with 13 additions and 11 deletions
  1. 13 11
      src/Components/Password/Steps/tree.js

+ 13 - 11
src/Components/Password/Steps/tree.js

17
 const checkedIcon = <CheckBoxIcon fontSize="small" />;
17
 const checkedIcon = <CheckBoxIcon fontSize="small" />;
18
 
18
 
19
 
19
 
20
-
21
 export function StepTree(props) {
20
 export function StepTree(props) {
22
 
21
 
23
     const PlazaScheme = Yup.object().shape({
22
     const PlazaScheme = Yup.object().shape({
31
 
30
 
32
     const formik = useFormik({
31
     const formik = useFormik({
33
         initialValues: {
32
         initialValues: {
34
-            puesto: password.index_pruebas
33
+            puesto: 
34
+            password.index_pruebas
35
         },
35
         },
36
         onSubmit: (fields) => {
36
         onSubmit: (fields) => {
37
-            console.log('PRUEBAS ::',fields)
37
+            console.log('PRUEBAS :: -> ',fields)
38
             setPassword({
38
             setPassword({
39
                 ...password,
39
                 ...password,
40
                 index_pruebas : fields.puesto
40
                 index_pruebas : fields.puesto
44
         validationSchema: PlazaScheme,
44
         validationSchema: PlazaScheme,
45
     });
45
     });
46
 
46
 
47
-    const {errors, touched, handleSubmit, getFieldProps, setValues} = formik;
47
+    const { errors, touched,handleSubmit, getFieldProps,setValues } = formik;
48
+
48
     return (
49
     return (
49
         <FormikProvider style={{ padding : 25 }} value={formik}>
50
         <FormikProvider style={{ padding : 25 }} value={formik}>
50
             <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
51
             <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
51
                 <Stack spacing={2}>
52
                 <Stack spacing={2}>
52
                     <Autocomplete
53
                     <Autocomplete
53
                         {...getFieldProps('puesto')}
54
                         {...getFieldProps('puesto')}
55
+                        onChange={(_a,current_list,_c,_individual,_f) => {
56
+                            setValues({
57
+                                puesto:current_list
58
+                            })
59
+                        }}
60
+                        isOptionEqualToValue={(option, value) => option.label === value.label}
54
                         multiple
61
                         multiple
55
                         id="checkboxes-tags-demo"
62
                         id="checkboxes-tags-demo"
56
                         options={top100Films}
63
                         options={top100Films}
58
                         getOptionLabel={(option) => { 
65
                         getOptionLabel={(option) => { 
59
                             return option.label 
66
                             return option.label 
60
                         }}
67
                         }}
61
-                        onChange={(_a,current_list,_c,_individual,_f) => {
62
-                            setValues({
63
-                                puesto:current_list
64
-                            })
65
-                        }}
66
                         renderOption={(props, option, { selected }) => (
68
                         renderOption={(props, option, { selected }) => (
67
                             <li {...props}>
69
                             <li {...props}>
68
                                 <Checkbox
70
                                 <Checkbox
69
                                     icon={delete_icon}
71
                                     icon={delete_icon}
70
                                     checkedIcon={checkedIcon}
72
                                     checkedIcon={checkedIcon}
71
-                                    // style={{ marginRight: 8 }}
73
+                                    style={{ marginRight: 8 }}
72
                                     checked={selected}
74
                                     checked={selected}
73
                                     />
75
                                     />
74
                                 {option.label}
76
                                 {option.label}
76
                         )}
78
                         )}
77
                         renderInput={(params) => (
79
                         renderInput={(params) => (
78
                             <TextField 
80
                             <TextField 
79
-                                {...getFieldProps('puesto')}
81
+                                // {...getFieldProps('puesto')}
80
                                 error={Boolean(touched.puesto && errors.puesto)}
82
                                 error={Boolean(touched.puesto && errors.puesto)}
81
                                 helperText={touched.puesto && errors.puesto}
83
                                 helperText={touched.puesto && errors.puesto}
82
                                 {...params} 
84
                                 {...params}