@@ -6,6 +6,7 @@ import type { InternalVfm, Modal, ModalId, UseModalOptions, UseModalOptionsPriva
6
6
export function createVfm ( ) {
7
7
const modals : ComputedRef < Modal > [ ] = shallowReactive ( [ ] )
8
8
const openedModals : ComputedRef < Modal > [ ] = shallowReactive ( [ ] )
9
+ const openedModalOverlays : ComputedRef < Modal > [ ] = shallowReactive ( [ ] )
9
10
const dynamicModals : ( UseModalOptions < any > & UseModalOptionsPrivate ) [ ] = shallowReactive ( [ ] )
10
11
const modalsContainers = ref < symbol [ ] > ( [ ] )
11
12
@@ -19,6 +20,7 @@ export function createVfm() {
19
20
} ,
20
21
modals,
21
22
openedModals,
23
+ openedModalOverlays,
22
24
dynamicModals,
23
25
modalsContainers,
24
26
get ( modalId : ModalId ) {
@@ -43,7 +45,7 @@ export function createVfm() {
43
45
}
44
46
45
47
function createInternalVfm ( vfm : Vfm ) {
46
- const { modals, openedModals, dynamicModals } = vfm
48
+ const { modals, openedModals, openedModalOverlays , dynamicModals } = vfm
47
49
48
50
const internalVfm : InternalVfm = {
49
51
deleteFromModals ( modal : ComputedRef < Modal > ) {
@@ -60,13 +62,22 @@ function createInternalVfm(vfm: Vfm) {
60
62
if ( index !== - 1 )
61
63
openedModals . splice ( index , 1 )
62
64
} ,
65
+ moveToLastOpenedModalOverlays ( modal : ComputedRef < Modal > ) {
66
+ internalVfm . deleteFromOpenedModalOverlays ( modal )
67
+ openedModalOverlays . push ( modal )
68
+ } ,
69
+ deleteFromOpenedModalOverlays ( modal : ComputedRef < Modal > ) {
70
+ const index = openedModalOverlays . findIndex ( _modal => _modal . value === modal . value )
71
+ if ( index !== - 1 )
72
+ openedModalOverlays . splice ( index , 1 )
73
+ } ,
63
74
async openLastOverlay ( ) {
64
75
await nextTick ( )
65
76
// Close all overlay first
66
- openedModals . forEach ( modal => modal . value . overlayVisible . value = false )
77
+ openedModalOverlays . forEach ( modal => modal . value . overlayVisible . value = false )
67
78
// Open the last overlay if it has overlay
68
- if ( openedModals . length > 0 ) {
69
- const modal = openedModals [ openedModals . length - 1 ]
79
+ if ( openedModalOverlays . length > 0 ) {
80
+ const modal = openedModalOverlays [ openedModalOverlays . length - 1 ]
70
81
! modal . value . hideOverlay ?. value && ( modal . value . overlayVisible . value = true )
71
82
}
72
83
} ,
0 commit comments