Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当popup嵌套时,关闭modal层级错乱问题 #1481

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/utils/popup/popup-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ const getModal = function() {
return modalDom;
};

/**
* 判断modalDom 是否是再其他 popup中嵌套,如果是嵌套则将modal 移动到最外层modal的父节点下面
* @param {最后一次生成的modalDom} modalDom
*/
const ifIsNested = function(modalDom) {
if (modalDom) {
if (modalDom.parentNode && modalDom.parentNode !== document.body) {
if (modalDom.parentNode.parentNode && modalDom.parentNode.parentNode.className && modalDom.parentNode.parentNode.className.indexOf('mint-popup') !== -1) {
modalDom.parentNode.parentNode.parentNode.appendChild(modalDom)
} else {
isNested(modalDom.parentNode)
}
}
}
}

const instances = {};

const PopupManager = {
Expand Down Expand Up @@ -133,6 +149,8 @@ const PopupManager = {
}
}
}

ifIsNested(modalDom)

if (modalStack.length === 0) {
if (this.modalFade) {
Expand Down