@@ -67,12 +67,14 @@ const getModalMaxZIndex = () => {
67
67
}
68
68
69
69
const getModalZIndexOffset = ( ) => getComponentConfig ( NAME , 'zIndexOffset' )
70
+ const getModalZIndexIncrement = ( ) => getComponentConfig ( NAME , 'zIndexIncrement' )
70
71
71
72
// Returns the next z-index to be used by a modal to ensure proper
72
73
// stacking regardless of document order.
73
- // The first modal open will be given a z-index of 0
74
74
const getModalNextZIndex = ( ) =>
75
- getModalOpenCount ( ) === 0 ? 0 : getModalMaxZIndex ( ) + getModalZIndexOffset ( )
75
+ getModalOpenCount ( ) === 0
76
+ ? getModalZIndexOffset ( )
77
+ : getModalMaxZIndex ( ) + getModalZIndexIncrement ( )
76
78
77
79
// @vue /component
78
80
export default {
@@ -272,7 +274,7 @@ export default {
272
274
is_opening : false , // Semaphore for preventing incorrect modal open counts
273
275
is_closing : false , // Semaphore for preventing incorrect modal open counts
274
276
scrollbarWidth : 0 ,
275
- zIndex : 0 , // z-index for modal stacking
277
+ zIndex : getModalZIndexOffset ( ) , // z-index for modal stacking
276
278
isTop : true , // If the modal is the topmost opened modal
277
279
isBodyOverflowing : false ,
278
280
return_focus : this . returnFocus || null
@@ -567,7 +569,7 @@ export default {
567
569
this . setEnforceFocus ( false )
568
570
this . $nextTick ( ( ) => {
569
571
this . is_hidden = this . lazy || false
570
- this . zIndex = 0
572
+ this . zIndex = getModalZIndexOffset ( )
571
573
this . returnFocusTo ( )
572
574
this . is_closing = false
573
575
const hiddenEvt = new BvEvent ( 'hidden' , {
@@ -659,8 +661,18 @@ export default {
659
661
this . isTop = this . zIndex >= getModalMaxZIndex ( )
660
662
} ,
661
663
modalListener ( bvEvt ) {
662
- // If another modal opens, close this one
664
+ // If another modal opens, close this one if stacking not permitted
663
665
if ( this . noStacking && bvEvt . vueTarget !== this ) {
666
+ // The next modal will have an incorrectly higher z-index than needed,
667
+ // because this modal will still be open when teh next zIndex is calculated.
668
+ //
669
+ // We need a way to postpone the next modal from opening until this
670
+ // one has closed, while maintaning the context of the original event
671
+ // that triggered the next modal to open.
672
+ //
673
+ // Perhaps a method on the BvEvent object that can be used to trigger a
674
+ // postpone, similar to preventDefault(), but delays the modal opening until
675
+ // a specific bv::modal::hidden event is triggered
664
676
this . hide ( )
665
677
}
666
678
} ,
0 commit comments