File tree Expand file tree Collapse file tree 2 files changed +13
-20
lines changed Expand file tree Collapse file tree 2 files changed +13
-20
lines changed Original file line number Diff line number Diff line change 14
14
type SchemaRow = { name: string , type: string , immutable: boolean };
15
15
16
16
const model = useModel ();
17
+ const defaultSchema = model .target ?.schema .map ((sch : SchemaRow ) => sch );
17
18
const form = useForm ({
18
19
initialValues: {
19
20
name: ' ' ,
20
- schema: [] ,
21
+ schema: defaultSchema ,
21
22
}
22
23
});
23
24
24
25
const isDisabled = computed (() => form .isSubmitting .value === true );
25
-
26
- const { remove, push, fields } = useFieldArray <SchemaRow >(' schema' );
27
-
28
- const resetDefaultSchema = () => {
29
- for (let i = 0 ; i < fields .value .length ; i ++ ) {
30
- remove (i );
31
- }
32
-
33
- model .target ?.schema .forEach ((sch : SchemaRow ) => {
34
- push (sch );
35
- });
36
- };
37
-
38
- watch (() => model .target , () => {
39
- // Temporary solution to reactively assign the
40
- // default schema to the form
41
- resetDefaultSchema ();
42
- });
26
+ const { fields } = useFieldArray <SchemaRow >(' schema' );
43
27
44
28
const handleClose = () => {
45
29
form .handleReset ();
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ type UseModal = {
16
16
open : ( ) => void ;
17
17
} ;
18
18
19
+ const sleep = ( ms : number ) => new Promise ( ( res ) => setTimeout ( ( ) => res ( ms ) , ms ) ) ;
20
+
19
21
/**
20
22
* A composable for managing modals.
21
23
*
@@ -42,6 +44,7 @@ export default function (
42
44
options : ModalProps = { id : 'base' }
43
45
) : UseModal {
44
46
const display = ref ( false ) ;
47
+ const refreshKey = ref ( new Date ( ) ) ;
45
48
46
49
const close = ( ) => {
47
50
display . value = false ;
@@ -51,7 +54,12 @@ export default function (
51
54
}
52
55
} ;
53
56
54
- const open = ( ) => {
57
+ const open = async ( ) => {
58
+ refreshKey . value = new Date ( ) ;
59
+
60
+ await nextTick ( ) ;
61
+ await sleep ( 50 ) ;
62
+
55
63
display . value = true ;
56
64
} ;
57
65
@@ -68,6 +76,7 @@ export default function (
68
76
render ( ) {
69
77
return h ( component , {
70
78
...options ,
79
+ key : refreshKey . value ,
71
80
onClose : close ,
72
81
} ) ;
73
82
} ,
You can’t perform that action at this time.
0 commit comments