From 77e0ae4b15d5999f5365f57b98555212b3f665df Mon Sep 17 00:00:00 2001 From: umsangdon Date: Thu, 1 Oct 2026 10:06:43 +0900 Subject: [PATCH] =?UTF-8?q?fix(m01-easycalc):=20=EC=B9=B4=EB=93=9C?= =?UTF-8?q?=EA=B0=80=20=EC=98=9B=20=ED=8C=90=EB=B3=B8=EC=9D=84=20=EC=A5=90?= =?UTF-8?q?=EB=8D=98=20=ED=9D=A0(=EC=A0=80=EC=9E=A5=20=EB=92=A4=20409)=20?= =?UTF-8?q?=C2=B7=20=EB=90=98=EB=8F=8C=EB=A6=AC=EA=B8=B0=20=EC=B9=B8=20?= =?UTF-8?q?=EB=8B=A4=EC=8B=9C=20=EA=B7=B8=EB=A6=BC=20=C2=B7=20=EB=8B=A8?= =?UTF-8?q?=EC=9C=84=20=ED=9B=84=EB=B3=B4=20=EB=8B=A4=EB=93=AC=EC=9D=8C=20?= =?UTF-8?q?=C2=B7=20=EB=B3=B8=EB=9C=AC=20=EB=92=A4=20=EC=95=8C=EB=A6=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt --- M01_MasterData/EasyCalc/M01_EasyCalc_Entry.ts | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/M01_MasterData/EasyCalc/M01_EasyCalc_Entry.ts b/M01_MasterData/EasyCalc/M01_EasyCalc_Entry.ts index 8705607b4..685fa5078 100644 --- a/M01_MasterData/EasyCalc/M01_EasyCalc_Entry.ts +++ b/M01_MasterData/EasyCalc/M01_EasyCalc_Entry.ts @@ -238,13 +238,16 @@ function openEasyCalc(): void { drawFound(); }; - /** 단위 고르기 후보 — 목록에 많이 쓰인 「원/…」 차례 */ + /** 단위 고르기 후보 — 목록에 다섯 번 넘게 쓰인 「원/…」 차례 · 설명 붙은 드문 단위는 뺌(연 로직 것은 따로 더함) */ const unitChoices = (): string[] => { const count = new Map(); for (const x of logics ?? []) { if (x.canOpen) count.set(x.resultUnit, (count.get(x.resultUnit) ?? 0) + 1); } - return [...count.entries()].sort((a, b) => b[1] - a[1]).map(([u]) => u); + return [...count.entries()] + .filter(([u, n]) => n >= 5 && !/[\s()「·]/.test(u)) + .sort((a, b) => b[1] - a[1]) + .map(([u]) => u); }; /* ---------- 고치는 화면 ---------- */ @@ -336,8 +339,8 @@ function openEasyCalc(): void { baseBar.hidden = !doc.isBase; }; - /** 금액 · 카드 · 표 — 계산 답이 올 때마다 · 바뀔 때마다 */ - const draw = (pending: boolean): void => { + /** 금액 · 카드 · 표 — 바뀔 때마다(pending) · 계산 답이 올 때마다(answer) */ + const draw = (pending: boolean, answer = false): void => { const value = ans?.ok ? formatMoney(ans.result ?? ans.sums?.["계"] ?? 0) : "—"; total.textContent = te("Total", { u: amountOf(doc.resultUnit), v: value }); total.classList.toggle("is-pending", pending); @@ -352,15 +355,28 @@ function openEasyCalc(): void { calc(); }); } - drawCards(); + drawCards(answer); renderSheet(sheetHost, { name: doc.name, resultUnit: doc.resultUnit }, ans); }; - /** 카드 칸에 글을 넣는 중이면 그 칸을 떠난 뒤 그림(넣던 글이 안 날아가게) */ - const drawCards = (): void => { - const typing = cardsHost.contains(document.activeElement) && document.activeElement !== null; - if (typing && document.activeElement instanceof HTMLInputElement) { - cardsHost.addEventListener("focusout", () => setTimeout(drawCards), { once: true }); + /** 계산 답만 왔을 때 카드 칸에 글을 넣는 중이면 그 칸을 떠난 뒤 그림(넣던 글이 안 날아가게). + * doc 가 바뀌면 늘 바로 그림 — 카드가 옛 doc 를 쥐고 있으면 그다음 조작이 옛 판본 위에 쌓임 */ + let waiting = false; + const drawCards = (answer = false): void => { + const active = document.activeElement; + if (answer && active instanceof HTMLInputElement && cardsHost.contains(active)) { + if (!waiting) { + waiting = true; + cardsHost.addEventListener( + "focusout", + () => + setTimeout(() => { + waiting = false; + drawCards(true); + }), + { once: true }, + ); + } return; } renderCards(cardsHost, doc, ans, { change: edit }); @@ -371,7 +387,7 @@ function openEasyCalc(): void { calcLater(toRow(doc), trial, (next, plain) => { ans = next; note.textContent = plain ?? ""; - draw(false); + draw(false, true); }); }; @@ -430,7 +446,7 @@ function openEasyCalc(): void { try { const saved = await copyEasy(doc.key); reopen(toDoc(saved.row, { key: saved.key, version: saved.version, isBase: false })); - note.textContent = te("Copied"); + showToast(te("Copied"), "success"); } catch (error) { note.textContent = plainError(error); } finally {