diff --git a/A00_Common/spreadsheet/spreadsheet_menu.ts b/A00_Common/spreadsheet/spreadsheet_menu.ts index a2af5138f..c47a50612 100644 --- a/A00_Common/spreadsheet/spreadsheet_menu.ts +++ b/A00_Common/spreadsheet/spreadsheet_menu.ts @@ -23,6 +23,7 @@ import { colMoreItems, copyCut, copyOnlyItems, + keepGridFocus, pasteItems, rowInsertItems, rowMoreItems, @@ -44,6 +45,7 @@ export function attachMenu(ctx: SpreadsheetContext): PartHandle { const menu = createMapContextMenu("ss"); ctx.root.append(menu.element); + keepGridFocus(ctx, menu.element); // 메뉴 동작 뒤 Ctrl+Z 등 키가 격자로 ctx.cellMenuExtra ??= () => []; // 칸 메뉴 있음 — 조건 만들기가 이 끝에 붙음 function isMerged(range: CellRange): boolean { diff --git a/A00_Common/spreadsheet/spreadsheet_menu_items.ts b/A00_Common/spreadsheet/spreadsheet_menu_items.ts index 649f8ed01..cfb14d7ce 100644 --- a/A00_Common/spreadsheet/spreadsheet_menu_items.ts +++ b/A00_Common/spreadsheet/spreadsheet_menu_items.ts @@ -83,6 +83,18 @@ function back(ctx: SpreadsheetContext): void { (ctx.editor as Editor).focus?.(); } +/** 항목을 누른 뒤 초점이 문서(body)에 떨어졌으면 격자로 — 창을 띄운 동작은 그 창이 초점을 가짐 */ +export function keepGridFocus(ctx: SpreadsheetContext, menuRoot: HTMLElement): void { + menuRoot.addEventListener( + "click", + () => + setTimeout(() => { + if (document.activeElement === document.body) back(ctx); + }), + true, + ); +} + /** 잘라내기 · 복사 — 초점을 격자로 되돌린 뒤 불러야 부품의 copy · cut 듣기가 받음(빈 복사 막음) */ export function copyCut(ctx: SpreadsheetContext, kind: "cut" | "copy"): void { back(ctx); diff --git a/resources/tester/test_b07_cross_overlay_extent.py b/resources/tester/test_b07_cross_overlay_extent.py index 86924d51a..c829dbf35 100644 --- a/resources/tester/test_b07_cross_overlay_extent.py +++ b/resources/tester/test_b07_cross_overlay_extent.py @@ -85,7 +85,8 @@ def test_node_bundle_measures_screen_overlay() -> None: assert set(extents) == {0, 85.05} # 측점 키는 0.01 m 로 끊는다(cross_station) x_min, x_max, y_min, y_max = extents[85.05] assert x_max == pytest.approx(13.8216, abs=1e-3) - assert x_min == pytest.approx(-10.4371, abs=1e-3) - assert y_max - y_min == pytest.approx(16.9505, abs=1e-3) + # 유입 집수정 끝 절토 = 암 1:0.4 → 토사 1:1.0 복합경사(91-4 · 옛 한 줄 −10.4371 · 16.9505) + assert x_min == pytest.approx(-11.6239, abs=1e-3) + assert y_max - y_min == pytest.approx(17.7502, abs=1e-3) # 0 m: 노폭 글자(2 mm, 세로 가운데 정렬)가 맨 위 — 글자 반높이 0.1 m 까지 assert extents[0][3] == pytest.approx(879.8831, abs=1e-3) diff --git a/ui_template/ui_template_context_menu.ts b/ui_template/ui_template_context_menu.ts index 3b787d4d3..4edc8545b 100644 --- a/ui_template/ui_template_context_menu.ts +++ b/ui_template/ui_template_context_menu.ts @@ -113,6 +113,18 @@ export function createMapContextMenu(blockClass: string): MapContextMenu { return entry; } + /** 화면 밖으로 나가면 안쪽으로 당김(오른쪽 · 아래 끝) — 열 때 · 하위 메뉴를 펼칠 때 */ + function fit(): void { + const x = parseFloat(element.style.left); + const y = parseFloat(element.style.top); + const box = element.getBoundingClientRect(); + const view = element.ownerDocument.defaultView ?? window; // 새 창에 옮겨진 패널(54-35) + const dx = Math.max(0, box.right - view.innerWidth + 4); + const dy = Math.max(0, box.bottom - view.innerHeight + 4); + if (dx) element.style.left = `${Math.max(x - dx, x - box.left)}px`; + if (dy) element.style.top = `${Math.max(y - dy, y - box.top)}px`; + } + return { element, open(x, y, items) { @@ -152,6 +164,7 @@ export function createMapContextMenu(blockClass: string): MapContextMenu { .forEach((other) => (other.textContent = other.textContent!.replace("▾", "▸"))); body.hidden = !willOpen; head.textContent = `${item.label} ${willOpen ? "▾" : "▸"}`; + fit(); // 펼친 하위가 화면 아래로 넘치면 메뉴를 올림 }); element.append(head, body); }); @@ -160,13 +173,7 @@ export function createMapContextMenu(blockClass: string): MapContextMenu { element.style.left = `${x}px`; element.style.top = `${y}px`; element.hidden = false; - // 화면 밖으로 나가면 안쪽으로 당김(오른쪽 · 아래 끝에서 연 메뉴) - const box = element.getBoundingClientRect(); - const view = element.ownerDocument.defaultView ?? window; // 새 창에 옮겨진 패널(54-35) - const dx = Math.max(0, box.right - view.innerWidth + 4); - const dy = Math.max(0, box.bottom - view.innerHeight + 4); - if (dx) element.style.left = `${Math.max(x - dx, x - box.left)}px`; - if (dy) element.style.top = `${Math.max(y - dy, y - box.top)}px`; + fit(); }, close, contains: (target) => target instanceof Node && element.contains(target),