diff --git a/src/utils/popup/index.js b/src/utils/popup/index.js index 0fc1bbd7d63..bea78e1467a 100644 --- a/src/utils/popup/index.js +++ b/src/utils/popup/index.js @@ -125,6 +125,8 @@ export default { PopupManager.zIndex = zIndex; } + PopupManager.openPopup(this._popupId); + if (modal) { if (this._closing) { PopupManager.closeModal(this._popupId); @@ -199,6 +201,7 @@ export default { }, doAfterClose() { + PopupManager.closePopup(); PopupManager.closeModal(this._popupId); this._closing = false; }, diff --git a/src/utils/popup/popup-manager.js b/src/utils/popup/popup-manager.js index 598f8b84da8..02a13751c6f 100644 --- a/src/utils/popup/popup-manager.js +++ b/src/utils/popup/popup-manager.js @@ -55,13 +55,13 @@ const PopupManager = { }, modalStack: [], + popupStack: [], - doOnModalClick: function() { - const topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1]; - if (!topItem) return; + doOnModalClick: function () { + const instance = getTopPopup(); + if (!instance) return; - const instance = PopupManager.getInstance(topItem.id); - if (instance && instance.closeOnClickModal) { + if (instance && instance.modal && instance.closeOnClickModal) { instance.close(); } }, @@ -109,6 +109,21 @@ const PopupManager = { this.modalStack.push({ id: id, zIndex: zIndex, modalClass: modalClass }); }, + openPopup: function (id) { + if (Vue.prototype.$isServer) return; + if (!id) return; + const popupStack = this.popupStack; + if (popupStack.includes(id)) return; + popupStack.push(id); + }, + + closePopup: function () { + const popupStack = this.popupStack; + if (popupStack.length > 0) { + popupStack.pop(); + } + }, + closeModal: function(id) { const modalStack = this.modalStack; const modalDom = getModal(); @@ -165,12 +180,13 @@ Object.defineProperty(PopupManager, 'zIndex', { } }); -const getTopPopup = function() { +const getTopPopup = function () { if (Vue.prototype.$isServer) return; - if (PopupManager.modalStack.length > 0) { - const topPopup = PopupManager.modalStack[PopupManager.modalStack.length - 1]; - if (!topPopup) return; - const instance = PopupManager.getInstance(topPopup.id); + if (PopupManager.popupStack.length > 0) { + const topPopupId = + PopupManager.popupStack[PopupManager.popupStack.length - 1]; + if (!topPopupId) return; + const instance = PopupManager.getInstance(topPopupId); return instance; }