fix(ui): 공용 확인 창 닫힐 때 초점을 연 자리로 되돌림 · Esc 로 취소

- showConfirmDialog: 열기 전 초점을 기억해 취소 · 확인 · Esc 로 닫힐 때 그 요소가 아직 화면에 있으면 되돌림
- 열리면 [취소]에 초점 — 뒤 칸에 글이 들어가지 않고 Esc 가 먹음 · Esc 는 확인 창만 닫음(뒤 창 · 페이지로 안 넘김)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Kyw9qnkJ94pC1A4PfpDtA
This commit is contained in:
2026-09-28 22:38:37 +09:00
co-authored by Claude Opus 5.5
parent db8d3d02d4
commit ee0475d0a4
+10 -1
View File
@@ -318,17 +318,26 @@ export function showConfirmDialog(message: string, confirmLabel = "확인"): Pro
const panel = el("div", { className: "ui-confirm__panel" });
const text = el("p", { className: "ui-confirm__message", text: message });
const actions = el("div", { className: "ui-confirm__actions" });
const back = document.activeElement as HTMLElement | null; // 닫힐 때 초점을 돌려놓을 자리
const done = (result: boolean): void => {
overlay.remove();
if (back?.isConnected && back !== document.body) back.focus({ preventScroll: true });
resolve(result);
};
const cancel = createButton({ label: "취소", variant: "ghost", onClick: () => done(false) });
actions.append(
createButton({ label: "취소", variant: "ghost", onClick: () => done(false) }),
cancel,
createButton({ label: confirmLabel, variant: "danger", onClick: () => done(true) }),
);
overlay.addEventListener("keydown", (ev) => {
if (ev.key !== "Escape") return;
ev.stopPropagation(); // 뒤 창 · 페이지 Esc 까지 닫지 않음
done(false);
});
panel.append(text, actions);
overlay.append(panel);
document.body.append(overlay);
cancel.focus(); // 창에 초점 — 뒤 칸에 글이 들어가지 않고 Esc 가 먹음
});
}