Explorar el Código

autocomple small fix

amenpunk hace 3 años
padre
commit
176a5459a3
Se han modificado 1 ficheros con 13 adiciones y 11 borrados
  1. 13 11
      src/Components/Password/Steps/tree.js

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

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