@@ -6,6 +6,7 @@ import type { InternalVfm, Modal, ModalId, UseModalOptions, UseModalOptionsPriva
66export function createVfm ( ) {
77 const modals : ComputedRef < Modal > [ ] = shallowReactive ( [ ] )
88 const openedModals : ComputedRef < Modal > [ ] = shallowReactive ( [ ] )
9+ const openedModalOverlays : ComputedRef < Modal > [ ] = shallowReactive ( [ ] )
910 const dynamicModals : ( UseModalOptions < any > & UseModalOptionsPrivate ) [ ] = shallowReactive ( [ ] )
1011 const modalsContainers = ref < symbol [ ] > ( [ ] )
1112
@@ -19,6 +20,7 @@ export function createVfm() {
1920 } ,
2021 modals,
2122 openedModals,
23+ openedModalOverlays,
2224 dynamicModals,
2325 modalsContainers,
2426 get ( modalId : ModalId ) {
@@ -43,7 +45,7 @@ export function createVfm() {
4345}
4446
4547function createInternalVfm ( vfm : Vfm ) {
46- const { modals, openedModals, dynamicModals } = vfm
48+ const { modals, openedModals, openedModalOverlays , dynamicModals } = vfm
4749
4850 const internalVfm : InternalVfm = {
4951 deleteFromModals ( modal : ComputedRef < Modal > ) {
@@ -60,13 +62,22 @@ function createInternalVfm(vfm: Vfm) {
6062 if ( index !== - 1 )
6163 openedModals . splice ( index , 1 )
6264 } ,
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+ } ,
6374 async openLastOverlay ( ) {
6475 await nextTick ( )
6576 // Close all overlay first
66- openedModals . forEach ( modal => modal . value . overlayVisible . value = false )
77+ openedModalOverlays . forEach ( modal => modal . value . overlayVisible . value = false )
6778 // 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 ]
7081 ! modal . value . hideOverlay ?. value && ( modal . value . overlayVisible . value = true )
7182 }
7283 } ,
0 commit comments