fix: POP 화면설정 iframe 매칭 — 정확/길이 긴 url 우선

문제: /pop/outbound/cart 진입 시 startsWith 매칭으로
      /pop/outbound(출고유형선택)가 먼저 잡혀 selectedScreen이 잘못 설정됨

해결: 정확 일치 1순위 + url 길이 긴 항목 startsWith 우선
This commit is contained in:
SeongHyun Kim
2026-04-07 18:23:36 +09:00
parent 444f0f95f3
commit dad8df7b10
@@ -830,13 +830,24 @@ export default function PopSettingsMngPage() {
const path = iframeRef.current?.contentWindow?.location.pathname;
if (path && path !== lastPath) {
setLastPath(path);
// 1순위: 정확 일치, 2순위: 길이 긴 url부터 startsWith 매칭 (구체적 경로 우선)
let bestMatch: ScreenItem | null = null;
let bestUrlLength = -1;
for (const group of SCREEN_GROUPS) {
const found = group.screens.find((s) => path === s.url || path.startsWith(s.url + "/"));
if (found) {
setSelectedScreen(found);
break;
for (const s of group.screens) {
if (path === s.url) {
bestMatch = s;
bestUrlLength = Infinity;
break;
}
if (path.startsWith(s.url + "/") && s.url.length > bestUrlLength) {
bestMatch = s;
bestUrlLength = s.url.length;
}
}
if (bestUrlLength === Infinity) break;
}
if (bestMatch) setSelectedScreen(bestMatch);
}
} catch {
// cross-origin: silently ignore