File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export { ELEMENT_REF, createNativeView } from './runtimeHelpers';
40
40
41
41
export * from '@vue/runtime-core' ;
42
42
export { vShow } from './directives/vShow' ;
43
- export { $showModal } from './plugins/modals' ;
43
+ export { $showModal , $closeModal } from './plugins/modals' ;
44
44
export { $navigateTo , $navigateBack } from './plugins/navigation' ;
45
45
46
46
// creates a special root container that calls resetRoot whenever it's children change
Original file line number Diff line number Diff line change @@ -61,6 +61,8 @@ function resolveModalTarget(
61
61
return false ;
62
62
}
63
63
64
+ const modalStack = [ ] ;
65
+
64
66
export async function $showModal < T = any , P = any > (
65
67
component : Component < P > ,
66
68
options : ShowModalOptions < P , T > = { } ,
@@ -127,6 +129,9 @@ export async function $showModal<T = any, P = any>(
127
129
} ) ;
128
130
} ;
129
131
const closeModal = ( ...args : any [ ] ) => {
132
+ // remove view from modalStack
133
+ modalStack . splice ( modalStack . indexOf ( view ) , 1 ) ;
134
+
130
135
view . nativeView ?. closeModal ( ...args ) ;
131
136
} ;
132
137
@@ -144,5 +149,12 @@ export async function $showModal<T = any, P = any>(
144
149
145
150
view . mount ( root ) ;
146
151
openModal ( ) ;
152
+ modalStack . push ( view ) ;
147
153
} ) ;
148
154
}
155
+
156
+ export function $closeModal ( ...args ) {
157
+ const view = modalStack . at ( - 1 ) ;
158
+
159
+ view ?. context . config . globalProperties . $closeModal ( ...args ) ;
160
+ }
You can’t perform that action at this time.
0 commit comments