Skip to content

Commit b75fc15

Browse files
authored
Update modal.js
1 parent eea82a2 commit b75fc15

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/components/modal/modal.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ const getModalMaxZIndex = () => {
6969
const getModalZIndexOffset = () => getComponentConfig(NAME, 'zIndexOffset')
7070

7171
// Returns the next z-index to be used by a modal to ensure proper
72-
// stacking regardless of document order
73-
const getModalNextZIndex = () => getModalMaxZIndex() + getModalZIndexOffset()
72+
// stacking regardless of document order.
73+
// The first modal open will be given a z-index of 0
74+
const getModalNextZIndex = () =>
75+
getModalOpenCount() === 0 ? 0 : getModalMaxZIndex() + getModalZIndexOffset()
7476

7577
// @vue/component
7678
export default {
@@ -336,8 +338,8 @@ export default {
336338
]
337339
},
338340
modalOuterStyle() {
341+
// Styles needed for proper stacking of modals
339342
return {
340-
// We only set these styles on the stacked modals (z-index > 0)
341343
position: 'absolute',
342344
zIndex: this.zIndex
343345
}
@@ -442,13 +444,22 @@ export default {
442444
}
443445
this.is_closing = true
444446
const hideEvt = new BvEvent('hide', {
447+
// BvEvent standard properties
445448
cancelable: true,
446449
vueTarget: this,
447450
target: this.$refs.modal,
448-
modalId: this.safeId(),
449451
// This could be the trigger element/component reference
450452
relatedTarget: null,
451-
isOK: trigger || null,
453+
// Modal specific properties and methods
454+
modalId: this.safeId(),
455+
// `isOK` should be deprecated:
456+
// isOK: {
457+
// get() {
458+
// warn(`b-modal: evt.isOK is deprecated. Please check evt.trigger === 'ok'`)
459+
// return trigger === 'ok'
460+
// }
461+
// }
462+
isOK: trigger === 'ok',
452463
trigger: trigger || null,
453464
cancel() /* istanbul ignore next */ {
454465
// Backwards compatibility
@@ -556,7 +567,7 @@ export default {
556567
this.setEnforceFocus(false)
557568
this.$nextTick(() => {
558569
this.is_hidden = this.lazy || false
559-
this.zIndex = getModalZIndexOffset()
570+
this.zIndex = 0
560571
this.returnFocusTo()
561572
this.is_closing = false
562573
const hiddenEvt = new BvEvent('hidden', {

0 commit comments

Comments
 (0)