From dad8df7b10d836cb1ae377c10f259e852568b18a Mon Sep 17 00:00:00 2001 From: SeongHyun Kim Date: Tue, 7 Apr 2026 18:23:36 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20POP=20=ED=99=94=EB=A9=B4=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20iframe=20=EB=A7=A4=EC=B9=AD=20=E2=80=94=20=EC=A0=95?= =?UTF-8?q?=ED=99=95/=EA=B8=B8=EC=9D=B4=20=EA=B8=B4=20url=20=EC=9A=B0?= =?UTF-8?q?=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: /pop/outbound/cart 진입 시 startsWith 매칭으로 /pop/outbound(출고유형선택)가 먼저 잡혀 selectedScreen이 잘못 설정됨 해결: 정확 일치 1순위 + url 길이 긴 항목 startsWith 우선 --- .../admin/screenMng/popSettingsMng/page.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/frontend/app/(main)/admin/screenMng/popSettingsMng/page.tsx b/frontend/app/(main)/admin/screenMng/popSettingsMng/page.tsx index 58085f8f..b00c69ad 100644 --- a/frontend/app/(main)/admin/screenMng/popSettingsMng/page.tsx +++ b/frontend/app/(main)/admin/screenMng/popSettingsMng/page.tsx @@ -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