fix(공용): 떠남 [취소] 뒤 단계 [<] [>] 흐려짐 — 주소 되돌림 알림 (PLAN 572)
- main.ts 취소 갈래 = replaceState 뒤 aislo:route-restored 냄(hashchange 가 안 뜸) - ui_template_help [<] [>] sync 가 그 알림에도 다시 맞춤 · 화면에서 빠지면 둘 다 풂 - test_401 소스 대조 하나 더함 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
|||||||
releaseSelectAfterPick,
|
releaseSelectAfterPick,
|
||||||
} from "@ui/ui_template_native_menu";
|
} from "@ui/ui_template_native_menu";
|
||||||
import { initLoupe, LOUPE_ROUTE } from "@ui/ui_template_loupe";
|
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 { ROUTES, type RoutePath } from "@config/config_frontend";
|
||||||
import { initThemeAndLang, injectShellStyles, renderShell } from "./app_shell";
|
import { initThemeAndLang, injectShellStyles, renderShell } from "./app_shell";
|
||||||
import {
|
import {
|
||||||
@@ -95,6 +96,7 @@ function bootstrap(): void {
|
|||||||
renderAll();
|
renderAll();
|
||||||
} else {
|
} else {
|
||||||
history.replaceState(null, "", shownHash); // 취소 — 머문 채 주소만 되돌림
|
history.replaceState(null, "", shownHash); // 취소 — 머문 채 주소만 되돌림
|
||||||
|
window.dispatchEvent(new Event(ROUTE_RESTORED_EVENT)); // 주소 따라 그린 것(단계 [<] [>])을 다시 맞춤
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -110,3 +110,11 @@ def test_공용이_도우미를_씀():
|
|||||||
for name in ("d02-points", "e02-ground", "e03-prob", "e04-settings", "e05-report"):
|
for name in ("d02-points", "e02-ground", "e03-prob", "e04-settings", "e05-report"):
|
||||||
assert f'"{name}": {{ bucket: "draft", scope: "project"' in state
|
assert f'"{name}": {{ bucket: "draft", scope: "project"' in state
|
||||||
assert '"e06-rock"' in state and '"e07-settings"' 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
|
||||||
|
|||||||
@@ -344,6 +344,9 @@ function createStepNavButton(step: -1 | 1): HTMLButtonElement {
|
|||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 떠남 [취소] 뒤 주소를 되돌렸다는 알림(`main.ts` 가 냄 · hashchange 가 안 뜸). */
|
||||||
|
export const ROUTE_RESTORED_EVENT = "aislo:route-restored";
|
||||||
|
|
||||||
/** 지금 주소의 묶음 · [<] [>] 차례 — 목록 밖이면 차례 -1 */
|
/** 지금 주소의 묶음 · [<] [>] 차례 — 목록 밖이면 차례 -1 */
|
||||||
function stepNavIndex(): { index: number; last: number } {
|
function stepNavIndex(): { index: number; last: number } {
|
||||||
const route = location.hash.replace(/^#\/?/, "").split("?")[0];
|
const route = location.hash.replace(/^#\/?/, "").split("?")[0];
|
||||||
@@ -364,11 +367,16 @@ export function placeHelpButton(actions: HTMLElement): void {
|
|||||||
prev.disabled = index <= 0;
|
prev.disabled = index <= 0;
|
||||||
next.disabled = index === last;
|
next.disabled = index === last;
|
||||||
};
|
};
|
||||||
|
// 떠남 [취소] 는 주소만 되돌림(hashchange 없음) — 「되돌림」 알림에도 다시 맞춤(572)
|
||||||
const onHash = (): void => {
|
const onHash = (): void => {
|
||||||
if (prev.isConnected) sync();
|
if (prev.isConnected) sync();
|
||||||
else window.removeEventListener("hashchange", onHash); // 화면에서 빠짐 — 풂
|
else {
|
||||||
|
window.removeEventListener("hashchange", onHash); // 화면에서 빠짐 — 풂
|
||||||
|
window.removeEventListener(ROUTE_RESTORED_EVENT, onHash);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
sync();
|
sync();
|
||||||
window.addEventListener("hashchange", onHash);
|
window.addEventListener("hashchange", onHash);
|
||||||
|
window.addEventListener(ROUTE_RESTORED_EVENT, onHash);
|
||||||
row.prepend(createHelpButton(), prev, next);
|
row.prepend(createHelpButton(), prev, next);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user