fix(erp-dialog): 모달 팝업 안에서 확인 창이 뒤에 깔려 안 보이던 문제
입출고 옵션(상품 정보) ✕ 지우기 등 모달 <dialog>(showModal) 안에서 erpConfirm 을 부르면 body 에 붙인 확인 창이 브라우저 맨 위 층 뒤에 깔려 보이지도 눌리지도 않았다. 모달이 열려 있을 때만 확인 창을 모달 <dialog> 껍데기로 감싸 그 위에 띄운다(Esc = 취소). 평소엔 예전 그대로. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -116,11 +116,23 @@
|
||||
var previous = document.activeElement;
|
||||
var closed = false;
|
||||
|
||||
// 모달 <dialog>(showModal — 브라우저 맨 위 층)가 열려 있으면 body 에 붙인 창은 그 뒤에 깔려 안 보이고 눌리지도 않는다
|
||||
// (예: 입출고 옵션 팝업 안 [지우기] 확인). 그때만 이 창도 모달 <dialog> 로 감싸 그 위에 띄운다. 평소엔 예전 그대로.
|
||||
var host = null;
|
||||
try {
|
||||
if (document.querySelector("dialog[open]:modal")) {
|
||||
host = document.createElement("dialog");
|
||||
host.className = "erp-dialog-host";
|
||||
host.addEventListener("cancel", function (e) { e.preventDefault(); close(false); }); // Esc = 취소
|
||||
}
|
||||
} catch (_) { host = null; } // :modal 을 모르는 아주 옛 브라우저
|
||||
|
||||
function close(result) {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
document.removeEventListener("keydown", onKey, true);
|
||||
el.backdrop.remove();
|
||||
if (host) { if (host.open) host.close(); host.remove(); }
|
||||
if (previous && typeof previous.focus === "function") previous.focus();
|
||||
// 입력창이면 확인 = 입력한 글자, 취소 = null
|
||||
if (el.input) resolve(result ? el.input.value : null);
|
||||
@@ -154,7 +166,13 @@
|
||||
});
|
||||
document.addEventListener("keydown", onKey, true);
|
||||
|
||||
document.body.appendChild(el.backdrop);
|
||||
if (host) {
|
||||
host.appendChild(el.backdrop);
|
||||
document.body.appendChild(host);
|
||||
host.showModal();
|
||||
} else {
|
||||
document.body.appendChild(el.backdrop);
|
||||
}
|
||||
if (el.input) { el.input.focus(); el.input.select(); }
|
||||
else el.ok.focus();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user