fix(856-G): 단가산출 머리 칸 Tab 초점 유지 — 이름 · 단위 고침이 머리를 다시 그리지 않음

- 까닭: 머리 칸 change 마다 머리 전체를 다시 그려 Tab 으로 옮긴 다음 칸(단위)이 새 칸으로 바뀌며 초점 · 타자가 끊김(불러온 식 미리 보기도 같은 화면)
- 고침: 칸 고침 = 문서 · 고침 알림만 · 단위 고침 · 환산 고침 = 환산 자리(display: contents)만 새로 그림 · 바탕 읽기 · 수식 저장 뒤 다시 그림은 그대로
- 일위대가 머리(이름 = input · 구분 = 같은 선택 칸 옵션만 바꿈)는 다시 그리지 않아 그대로
- 시험: test_856_0_sk_screen ⑥ 이름 · 단위 change 뒤 머리 칸 같은 칸 · 환산 다시 그린 수 · 문서(옛 코드 = 칸 바뀜 실패 확인) · 가짜 칸이 머리 나무에 달리게 · 사건 일으킴 더함
- 화면 8009: 새 단가산출(sub7임시) 이름 타자 → Tab → 단위 칸 초점 · 타자 m2 → Tab → 다음 단추 · [저장] · 다시 열기 같음 · 지움 · 콘솔 0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 05:00:18 +09:00
co-authored by Claude Opus 5.5
parent 24a685806f
commit 024a0b07ad
4 changed files with 91 additions and 18 deletions
@@ -29,6 +29,11 @@
min-width: 120px;
}
/* 856-G 환산 자리 — 머리 줄 배치에 안 끼어듦 */
.m02-sk__swap-slot {
display: contents;
}
.m02-sk__tags {
display: flex;
flex-wrap: wrap;
@@ -161,6 +161,7 @@ export function mountSangeunDetail(
};
function drawHead(): void {
// 856-G 칸 고침 = 머리를 다시 그리지 않음(Tab 으로 옮긴 다음 칸 초점 · 타자 유지) · 환산만 새로
const field = (label: string, key: "이름" | "단위"): HTMLElement => {
const box = createInputField({ label, value: doc[key] ?? "", compact: true, size: 28 });
box.input.dataset.sk = key;
@@ -168,29 +169,36 @@ export function mountSangeunDetail(
box.input.addEventListener("change", () => {
doc[key] = box.input.value.trim();
box.setError(doc[key] ? undefined : L("M02_SangeunNeed"));
touch();
report();
if (key === "단위") drawSwap();
});
return box.root;
};
const baseName = base ? `${base.logic.키} ${base.logic.이름}` : null;
const baseText = baseName ?? doc.바탕?.참조?.키 ?? L("M02_SangeunNoBase");
const swap = base
? buildUnitSwap({
result: base.logic.결과단위,
unit: doc.단위 ?? "",
how: doc.환산 as SwapHow | undefined,
edit,
onChange: (how) => {
if (how) doc.환산 = how;
else delete doc.환산;
touch();
},
})
: null;
const swapSlot = el("span", { className: "m02-sk__swap-slot" });
const drawSwap = (): void => {
const swap = base
? buildUnitSwap({
result: base.logic.결과단위,
unit: doc.단위 ?? "",
how: doc.환산 as SwapHow | undefined,
edit,
onChange: (how) => {
if (how) doc.환산 = how;
else delete doc.환산;
report();
drawSwap();
},
})
: null;
swapSlot.replaceChildren(...(swap ? [swap] : []));
};
drawSwap();
head.replaceChildren(
field(L("M02_Name"), "이름"),
field(L("M02_SangeunUnit"), "단위"),
...(swap ? [swap] : []),
swapSlot,
el("div", {
className: "m02-sk__tags",
attrs: { "data-sk-base": baseKey() ?? "" },
+52 -3
View File
@@ -40,8 +40,14 @@ class Fake {
get firstChild() {
return this.children[0] ?? null;
}
addEventListener() {}
addEventListener(t, f) {
((this.on ??= {})[t] ??= []).push(f);
}
removeEventListener() {}
/** 사건 일으킴(⑥ 머리 칸 change) */
fire(t) {
for (const f of this.on?.[t] ?? []) f({ target: this });
}
setAttribute(k, v) {
this.attrs[k] = v;
if (k.startsWith("data-")) this.dataset[camel(k.slice(5))] = v;
@@ -87,7 +93,9 @@ const button = (o = {}) => box("button", { "data-button": o.label ?? "" });
const input = (o = {}) => {
const i = box("input");
i.value = o.value ?? "";
return { root: box("label", { "data-input": o.label ?? "" }, ""), input: i, setError() {} };
const root = box("label", { "data-input": o.label ?? "" }, "");
root.append(i); // ⑥ 칸이 머리 나무에 달림
return { root, input: i, setError() {} };
};
const modals = []; // 열린 모달 — 제목 · 몸
const ui = {
@@ -193,7 +201,10 @@ const stubs = {
tabOf: () => ({}),
},
M01_MasterData_UI_LogicLab_Ho: { buildHo: () => [box("div", { "data-ho": "" })] },
M02_MasterTemplete_Sangeun_Unit: { buildUnitSwap: () => null, baseUnitOf: () => "" },
M02_MasterTemplete_Sangeun_Unit: {
buildUnitSwap: () => (swaps.n++, box("div", { "data-swap": "" })), // ⑥ 환산 다시 그린 수
baseUnitOf: () => "",
},
M02_MasterTemplete_Labor_LogicMats: { logicMatRows: () => [] },
M02_Labor_Values_Model: {
valueLine: () => ({ text: "", empty: 0 }),
@@ -219,6 +230,7 @@ const stubs = {
},
};
const picked = { rows: 0 };
const swaps = { n: 0 };
const real = new Set([
"M02_MasterTemplete_Sangeun_Detail",
"M02_MasterTemplete_Sangeun_Tabs",
@@ -460,6 +472,43 @@ async function openSk(doc, opt = {}) {
};
}
globalThis.fetch = fetch0;
// ⑥ 머리 칸 고침(856-G) — 이름 change 뒤 머리 칸 그대로(Tab 으로 옮긴 단위 칸 = 같은 칸 · 초점 유지) ·
// 단위 change = 환산만 새로 · 문서 · 고침 알림
{
const { mountSangeunDetail } = M("M02_MasterTemplete/M02_MasterTemplete_Sangeun_Detail.ts");
const host = box("div");
let dirty = false;
const doc = { 키: "SK-000011", 이름: "견본", 단위: "㎡", 바탕: { 로직: "GC001109" } };
const h = mountSangeunDetail(host, doc, {
layer: "system",
owner: null,
readOnly: false,
mode: "page",
onChanged: (d) => (dirty = d),
});
await settle();
const fields = () => all(host, (n) => n.dataset.sk === "이름" || n.dataset.sk === "단위");
const before = fields();
const [name, unit] = before;
const same = () => fields().length === 2 && fields().every((n, i) => n === before[i]);
let n0 = swaps.n;
name.value = " 고친 이름 ";
name.fire("change");
const afterName = { same: same(), swaps: swaps.n - n0, dirty };
n0 = swaps.n;
unit.value = "m2";
unit.fire("change");
const afterUnit = { same: same(), swaps: swaps.n - n0, shown: all(host, (n) => "swap" in n.dataset).length }; // prettier-ignore
const got = h.getDoc();
out.head = {
order: before.map((n) => n.dataset.sk),
afterName,
afterUnit,
doc: [got.이름, got.단위],
};
h.destroy();
}
console.log(JSON.stringify(out));
})().catch((e) => {
console.error(e.stack || String(e));
+11
View File
@@ -6,6 +6,7 @@
③ 머리 띠(까닭 · M01 개정 · 빠진 줄)가 뜨는 경우 — 줄 쌓기 셈 답 · 사본 표지 견본(856-2 · 짝 잃음 = 덮개 없음)
④ M01 로직 상세 그릇 = 기본정보 접힘 + 줄 쌓기
⑤ 줄 쌓기 [+ 줄] 찾아 넣기 — 빈 낱말로 열어도 종류마다 서버 찾기 · 목록이 그려짐(856-F)
⑥ 머리 칸 고침 — 이름 · 단위 change 뒤 머리 칸 그대로(Tab 으로 옮긴 다음 칸 초점 유지 · 856-G) · 환산만 새로
"""
from __future__ import annotations
@@ -100,3 +101,13 @@ def test_stack_find_lists_each_kind() -> None:
got = find[f"{side}_{kind}"]
assert got["paths"] == paths, (side, kind, got)
assert got["rows"] >= 1, (side, kind, got)
def test_head_edit_keeps_fields() -> None:
got = _run()["head"]
assert got["order"] == ["이름", "단위"]
# 이름 고침 → 머리를 다시 그리지 않음 = Tab 으로 간 단위 칸이 같은 칸(초점 · 타자 유지) · 고침 알림
assert got["afterName"] == {"same": True, "swaps": 0, "dirty": True}
# 단위 고침 → 칸 그대로 · 환산 자리만 새로 그림
assert got["afterUnit"] == {"same": True, "swaps": 1, "shown": 1}
assert got["doc"] == ["고친 이름", "m2"]