diff --git a/A00_Common/main.ts b/A00_Common/main.ts index 647de8f24..cd89db516 100644 --- a/A00_Common/main.ts +++ b/A00_Common/main.ts @@ -19,6 +19,7 @@ import { releaseSelectAfterPick, } from "@ui/ui_template_native_menu"; import { initLoupe, LOUPE_ROUTE } from "@ui/ui_template_loupe"; +import { ROUTE_RESTORED_EVENT } from "@ui/ui_template_help"; import { ROUTES, type RoutePath } from "@config/config_frontend"; import { initThemeAndLang, injectShellStyles, renderShell } from "./app_shell"; import { @@ -95,6 +96,7 @@ function bootstrap(): void { renderAll(); } else { history.replaceState(null, "", shownHash); // 취소 — 머문 채 주소만 되돌림 + window.dispatchEvent(new Event(ROUTE_RESTORED_EVENT)); // 주소 따라 그린 것(단계 [<] [>])을 다시 맞춤 } }); }); diff --git a/resources/tester/test_401_project_isolation.py b/resources/tester/test_401_project_isolation.py index fb8a5f388..d6b34f811 100644 --- a/resources/tester/test_401_project_isolation.py +++ b/resources/tester/test_401_project_isolation.py @@ -110,3 +110,11 @@ def test_공용이_도우미를_씀(): for name in ("d02-points", "e02-ground", "e03-prob", "e04-settings", "e05-report"): assert f'"{name}": {{ bucket: "draft", scope: "project"' in state assert '"e06-rock"' in state and '"e07-settings"' in state + + +def test_떠남_취소_뒤_단계_단추_다시_맞춤(): + # [취소] = 주소만 되돌림(hashchange 없음) → 「되돌림」 알림으로 [<] [>] 다시 맞춤 + main = (ROOT / "A00_Common/main.ts").read_text(encoding="utf-8") + assert "window.dispatchEvent(new Event(ROUTE_RESTORED_EVENT))" in main + help_ts = (ROOT / "ui_template/ui_template_help.ts").read_text(encoding="utf-8") + assert "window.addEventListener(ROUTE_RESTORED_EVENT, onHash);" in help_ts diff --git a/ui_template/ui_template_help.ts b/ui_template/ui_template_help.ts index fdc0de27d..bdacf8f0c 100644 --- a/ui_template/ui_template_help.ts +++ b/ui_template/ui_template_help.ts @@ -344,6 +344,9 @@ function createStepNavButton(step: -1 | 1): HTMLButtonElement { return button; } +/** 떠남 [취소] 뒤 주소를 되돌렸다는 알림(`main.ts` 가 냄 · hashchange 가 안 뜸). */ +export const ROUTE_RESTORED_EVENT = "aislo:route-restored"; + /** 지금 주소의 묶음 · [<] [>] 차례 — 목록 밖이면 차례 -1 */ function stepNavIndex(): { index: number; last: number } { const route = location.hash.replace(/^#\/?/, "").split("?")[0]; @@ -364,11 +367,16 @@ export function placeHelpButton(actions: HTMLElement): void { prev.disabled = index <= 0; next.disabled = index === last; }; + // 떠남 [취소] 는 주소만 되돌림(hashchange 없음) — 「되돌림」 알림에도 다시 맞춤(572) const onHash = (): void => { if (prev.isConnected) sync(); - else window.removeEventListener("hashchange", onHash); // 화면에서 빠짐 — 풂 + else { + window.removeEventListener("hashchange", onHash); // 화면에서 빠짐 — 풂 + window.removeEventListener(ROUTE_RESTORED_EVENT, onHash); + } }; sync(); window.addEventListener("hashchange", onHash); + window.addEventListener(ROUTE_RESTORED_EVENT, onHash); row.prepend(createHelpButton(), prev, next); }