fix(split-panel-layout2): 좌측 패널 항목 선택 상태 비교 로직 개선

- idColumn 자동 감지 로직 추가 (id > dept_code > code 순 폴백)
- isSelected 비교 시 객체 동일성 및 undefined 체크 추가
- hierarchyConfig.idColumn 미설정 시에도 정상 동작
This commit is contained in:
SeongHyun Kim 2025-12-09 09:22:10 +09:00
parent d908de7f66
commit fa59235cd2
1 changed files with 13 additions and 2 deletions

View File

@ -812,11 +812,22 @@ export const SplitPanelLayout2Component: React.FC<SplitPanelLayout2ComponentProp
// 좌측 패널 항목 렌더링
const renderLeftItem = (item: any, level: number = 0, index: number = 0) => {
const idColumn = config.leftPanel?.hierarchyConfig?.idColumn || "id";
// ID 컬럼 결정: 설정값 > 데이터에 존재하는 일반적인 ID 컬럼 > 폴백
const configIdColumn = config.leftPanel?.hierarchyConfig?.idColumn;
const idColumn = configIdColumn ||
(item["id"] !== undefined ? "id" :
item["dept_code"] !== undefined ? "dept_code" :
item["code"] !== undefined ? "code" : "id");
const itemId = item[idColumn] ?? `item-${level}-${index}`;
const hasChildren = item.children?.length > 0;
const isExpanded = expandedItems.has(String(itemId));
const isSelected = selectedLeftItem && selectedLeftItem[idColumn] === item[idColumn];
// 선택 상태 확인: 동일한 객체이거나 idColumn 값이 일치해야 함
const isSelected = selectedLeftItem && (
selectedLeftItem === item ||
(item[idColumn] !== undefined &&
selectedLeftItem[idColumn] !== undefined &&
selectedLeftItem[idColumn] === item[idColumn])
);
// displayRow 설정에 따라 컬럼 분류
const displayColumns = config.leftPanel?.displayColumns || [];