diff --git a/app/modules/performance/CLAUDE.md b/app/modules/performance/CLAUDE.md index 21acbf3..cceb2a7 100644 --- a/app/modules/performance/CLAUDE.md +++ b/app/modules/performance/CLAUDE.md @@ -57,6 +57,8 @@ 묶어 상자 안에서 스크롤했는데, 진짜 셸에서는 상자 아래가 화면 밖에 잘리고(`overscroll-behavior: contain`) 휠이 페이지로 안 넘어갔다. 스크롤 막대 배경(트랙) 투명 = `scrollbar-color: #c3c6cb transparent`(표 상자·실적 화면 `.erp-page`). 테스트 `tests/js/perf_sticky.browser.test.js` (진짜 `erp_base.html` 셸 렌더 `perf_*_shell.html` 로 휠 스크롤 — 스텁 셸로는 이 문제가 안 보였다). +- **새로고침해도 스크롤 유지**(2026-11-02) — 수기 입력을 마치면 합계를 다시 계산하려고 새로고침하는데, 세로 스크롤은 `.erp-page` 상자라 브라우저가 복원하지 않아 맨 위로 돌아갔다. + `performance.js keepScroll` 이 떠날 때 세로·가로 위치를 sessionStorage `perf_scroll` 에 저장 → **새로고침일 때만** 복원(같은 주소, 메뉴·기간 이동은 맨 위부터). 자동 새로 고침·업로드 뒤 새로고침도 같음. - 열 순서 카페24·네이버·쿠팡(윙)·쿠팡(로켓)·오늘의집·G마켓·카카오·GS샵·11번가·롯데ON·토스·애터미아자몰(마이그레이션 003). - 쿠팡(로켓)·애터미아자몰은 **수동 입력 전용**(`adapters/manual.py`, `manual_only` — 매출 업데이트에서 빠지고 인증 설정·연결 테스트 없음, 수동 입력 늘 켜짐). - **직접 추가 쇼핑몰·그룹·순서 드래그**(2026-10-22, 마이그레이션 009 `is_custom`·`is_group`·`parent_code`) — 설정 [+ 쇼핑몰 추가(수동 입력)] diff --git a/app/modules/performance/templates/performance/ads.html b/app/modules/performance/templates/performance/ads.html index 9ef77a1..2f39c97 100644 --- a/app/modules/performance/templates/performance/ads.html +++ b/app/modules/performance/templates/performance/ads.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {#- ROAS 덧붙임 — "광고비(ROAS%)". 광고비가 없으면 아무것도 안 붙는다. -#} {%- macro roas(p) -%}{%- if p is not none -%}({{ "{:,}".format(p) }}%){%- endif -%}{%- endmacro -%} @@ -237,4 +237,4 @@ } | tojson }} {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/performance/templates/performance/index.html b/app/modules/performance/templates/performance/index.html index 408740a..9115744 100644 --- a/app/modules/performance/templates/performance/index.html +++ b/app/modules/performance/templates/performance/index.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {%- macro won(v) -%} {%- if v is none -%} @@ -294,4 +294,4 @@ } | tojson }} {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/performance/templates/performance/settings.html b/app/modules/performance/templates/performance/settings.html index 845a38d..1fbba9f 100644 --- a/app/modules/performance/templates/performance/settings.html +++ b/app/modules/performance/templates/performance/settings.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {%- macro when(v) -%}{{ (v or '')[:16] | replace('T', ' ') or '—' }}{%- endmacro -%} @@ -347,4 +347,4 @@ {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/static/performance.js b/app/static/performance.js index bb4050e..a3d99e3 100644 --- a/app/static/performance.js +++ b/app/static/performance.js @@ -1775,9 +1775,30 @@ }); } + // 새로고침해도 스크롤 위치 유지(2026-11-02) — 수기 입력·자동 새로 고침·업로드 뒤 새로고침 모두. 세로는 안쪽 스크롤 상자(.erp-page)라 + // 브라우저가 복원하지 않고, 가로는 표 상자. 떠날 때 저장 → 새로고침으로 다시 열릴 때만 복원(메뉴·기간 이동으로 들어오면 맨 위부터). + function keepScroll(root) { + const wrap = root.querySelector(".perf-main-wrap"); + if (!wrap) return; + const KEY = "perf_scroll"; + const scroller = function () { return scrollParent(wrap) || document.scrollingElement; }; + window.addEventListener("pagehide", function () { + try { sessionStorage.setItem(KEY, JSON.stringify({ url: location.href, top: scroller().scrollTop, left: wrap.scrollLeft })); } catch (_) { /* 기억만 못 함 */ } + }); + let saved = null; + try { + saved = JSON.parse(sessionStorage.getItem(KEY) || "null"); + sessionStorage.removeItem(KEY); + } catch (_) { saved = null; } + const nav = window.performance && performance.getEntriesByType ? performance.getEntriesByType("navigation")[0] : null; + if (!saved || saved.url !== location.href || !nav || nav.type !== "reload") return; + scroller().scrollTop = saved.top; + wrap.scrollLeft = saved.left; + } + document.addEventListener("DOMContentLoaded", function () { const dash = document.getElementById("perf-dash"); - if (dash) { initDashboard(dash); stickyHead(dash); } + if (dash) { initDashboard(dash); stickyHead(dash); keepScroll(dash); } const set = document.getElementById("perf-settings"); if (set) initSettings(set); }); diff --git a/tests/js/perf_sticky.browser.test.js b/tests/js/perf_sticky.browser.test.js index eaf51d3..7ab0219 100644 --- a/tests/js/perf_sticky.browser.test.js +++ b/tests/js/perf_sticky.browser.test.js @@ -101,6 +101,30 @@ async function stickyFlow(browser, file, label) { await p.waitForTimeout(120); const g4 = await geo(); check(label + " 맨 위로 돌아오면 제자리", Math.abs(g4.headTop - g0.headTop) <= 1 && Math.abs(g4.totalTop - g4.headBottom) <= 1, g4); + // 수기 입력 뒤 새로고침 — 세로·가로 스크롤 위치 그대로, 제목 행도 다시 화면 위(2026-11-02) + const pos = function () { + return p.evaluate(function () { + const wrap = document.querySelector(".perf-main-wrap"), page = document.querySelector(".erp-page"); + return { top: page.scrollTop, left: wrap.scrollLeft, headTop: document.querySelector(".perf-main thead th").getBoundingClientRect().top, pageTop: page.getBoundingClientRect().top }; + }); + }; + await p.evaluate(function () { document.querySelector(".erp-page").scrollTop = 500; document.querySelector(".perf-main-wrap").scrollLeft = 120; }); + await p.waitForTimeout(80); + const before = await pos(); + await Promise.all([p.waitForNavigation(), p.evaluate(function () { + document.querySelector('td.is-manual-cell[data-date="2026-10-20"]').click(); + const input = document.querySelector(".perf-manual-input"); + input.value = "5000"; + input.blur(); + })]); + await p.waitForTimeout(150); + const after = await pos(); + check(label + " 수기 입력 뒤 새로고침해도 스크롤 위치 그대로", before.top === 500 && before.left > 0 && after.top === before.top && after.left === before.left && + Math.abs(after.headTop - after.pageTop) <= 1, { before: before, after: after }); + // 새로고침이 아닌 이동(같은 주소로 다시 들어옴)은 맨 위부터 + await p.goto("http://perf.test/performance/"); + await p.waitForTimeout(150); + check(label + " 새로 들어오면 맨 위부터", (await pos()).top === 0); await ctx.close(); }