Skip to content

Commit 5eb49cf

Browse files
committed
AC-112: Modal z-index error when deleting item from cart
- Fixed z-index calculation using jQuery UI implementation - Fixed styling
1 parent 84b69d1 commit 5eb49cf

File tree

1 file changed

+39
-8
lines changed
  • app/code/Magento/Ui/view/base/web/js/modal

1 file changed

+39
-8
lines changed

app/code/Magento/Ui/view/base/web/js/modal/modal.js

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ define([
2424
* Detect browser transition end event.
2525
* @return {String|undefined} - transition event.
2626
*/
27-
var transitionEvent = (function () {
27+
var transitionEvent = (function () {
2828
var transition,
2929
elementStyle = document.createElement('div').style,
3030
transitions = {
@@ -39,7 +39,39 @@ define([
3939
return transitions[transition];
4040
}
4141
}
42-
})();
42+
})(),
43+
44+
/**
45+
* Implementation of zIndex used from jQuery UI
46+
* @param {Element} elem
47+
* @private
48+
*/
49+
getZIndex = function (elem) {
50+
var position, zIndex;
51+
52+
/* eslint-disable max-depth */
53+
while (elem.length && elem[ 0 ] !== document) {
54+
// Ignore z-index if position is set to a value where z-index is ignored by the browser
55+
// This makes behavior of this function consistent across browsers
56+
// WebKit always returns auto if the element is positioned
57+
position = elem.css('position');
58+
59+
if (position === 'absolute' || position === 'relative' || position === 'fixed') {
60+
// IE returns 0 when zIndex is not specified
61+
// other browsers return a string
62+
// we ignore the case of nested elements with an explicit value of 0
63+
zIndex = parseInt(elem.css('zIndex'), 10);
64+
65+
if (!isNaN(zIndex) && zIndex !== 0) {
66+
return zIndex;
67+
}
68+
}
69+
elem = elem.parent();
70+
}
71+
72+
return 0;
73+
/* eslint-enable max-depth */
74+
};
4375

4476
/**
4577
* Modal Window Widget
@@ -341,18 +373,17 @@ define([
341373
* Set z-index and margin for modal and overlay.
342374
*/
343375
_setActive: function () {
344-
var zIndex = this.modal.zIndex(),
376+
var zIndex = getZIndex(this.modal),
345377
baseIndex = zIndex + this._getVisibleCount();
346378

347379
if (this.modal.data('active')) {
348380
return;
349381
}
350-
351382
this.modal.data('active', true);
352383

353-
this.overlay.zIndex(++baseIndex);
354-
this.prevOverlayIndex = this.overlay.zIndex();
355-
this.modal.zIndex(this.overlay.zIndex() + 1);
384+
this.overlay.css('z-index', ++baseIndex);
385+
this.prevOverlayIndex = baseIndex;
386+
this.modal.css('z-index', baseIndex + 1);
356387

357388
if (this._getVisibleSlideCount()) {
358389
this.modal.css('marginLeft', this.options.modalLeftMargin * this._getVisibleSlideCount());
@@ -367,7 +398,7 @@ define([
367398
this.modal.data('active', false);
368399

369400
if (this.overlay) {
370-
this.overlay.zIndex(this.prevOverlayIndex - 1);
401+
this.overlay.css('z-index', this.prevOverlayIndex - 1);
371402
}
372403
},
373404

0 commit comments

Comments
 (0)