fix(pop-card-list): 원본 컴포넌트 선택 안 되는 문제 수정

- CartListModeConfig에 sourceComponentId 추가
- cartType이 빈 문자열인 경우 componentId로 매칭
- Select value: sourceComponentId 기반 안정적 매칭
- 런타임: sourceComponentId > cartType > 첫 번째 순으로 폴백

원인: 4160 화면의 cartAction에 cartType 미설정 -> 빈 문자열 ->
Select 저장 시 undefined 순환 -> 선택 불가
This commit is contained in:
SeongHyun Kim 2026-02-27 15:16:37 +09:00
parent c1cf31f57b
commit 220e05d2ae
3 changed files with 22 additions and 11 deletions

View File

@ -515,13 +515,16 @@ export function PopCardListComponent({
const layoutJson = await screenApi.getLayoutPop(cartListMode.sourceScreenId); const layoutJson = await screenApi.getLayoutPop(cartListMode.sourceScreenId);
const componentsMap = layoutJson?.components || {}; const componentsMap = layoutJson?.components || {};
const componentList = Object.values(componentsMap) as any[]; const componentList = Object.values(componentsMap) as any[];
const matched = cartListMode.cartType // sourceComponentId > cartType > 첫 번째 pop-card-list 순으로 매칭
? componentList.find( const matched = cartListMode.sourceComponentId
(c: any) => ? componentList.find((c: any) => c.id === cartListMode.sourceComponentId)
c.type === "pop-card-list" && : cartListMode.cartType
c.config?.cartAction?.cartType === cartListMode.cartType ? componentList.find(
) (c: any) =>
: componentList.find((c: any) => c.type === "pop-card-list"); c.type === "pop-card-list" &&
c.config?.cartAction?.cartType === cartListMode.cartType
)
: componentList.find((c: any) => c.type === "pop-card-list");
if (matched?.config?.cardTemplate) { if (matched?.config?.cardTemplate) {
setInheritedTemplate(matched.config.cardTemplate); setInheritedTemplate(matched.config.cardTemplate);
} }

View File

@ -933,15 +933,18 @@ function CartListModeSection({
const handleComponentSelect = (val: string) => { const handleComponentSelect = (val: string) => {
if (val === "__none__") { if (val === "__none__") {
onUpdate({ ...mode, cartType: undefined }); onUpdate({ ...mode, cartType: undefined, sourceComponentId: undefined });
return; return;
} }
// cartType 직접 매칭 또는 componentId 매칭 (__comp_ 접두사)
const found = val.startsWith("__comp_") const found = val.startsWith("__comp_")
? sourceCardLists.find((c) => c.componentId === val.replace("__comp_", "")) ? sourceCardLists.find((c) => c.componentId === val.replace("__comp_", ""))
: sourceCardLists.find((c) => c.cartType === val); : sourceCardLists.find((c) => c.cartType === val);
if (found) { if (found) {
onUpdate({ ...mode, cartType: found.cartType || undefined }); onUpdate({
...mode,
sourceComponentId: found.componentId,
cartType: found.cartType || undefined,
});
} }
}; };
@ -997,7 +1000,11 @@ function CartListModeSection({
</div> </div>
) : ( ) : (
<Select <Select
value={mode.cartType || "__none__"} value={
mode.sourceComponentId
? (sourceCardLists.find(c => c.componentId === mode.sourceComponentId)?.cartType || `__comp_${mode.sourceComponentId}`)
: mode.cartType || "__none__"
}
onValueChange={handleComponentSelect} onValueChange={handleComponentSelect}
> >
<SelectTrigger className="mt-1 h-7 text-xs"> <SelectTrigger className="mt-1 h-7 text-xs">

View File

@ -613,6 +613,7 @@ export interface CardResponsiveConfig {
export interface CartListModeConfig { export interface CartListModeConfig {
enabled: boolean; enabled: boolean;
sourceScreenId?: number; sourceScreenId?: number;
sourceComponentId?: string;
cartType?: string; cartType?: string;
statusFilter?: string; statusFilter?: string;
} }