fix(pop): 카테고리 트리 접기/펼치기 상태를 sessionStorage로 유지
설계 화면에 진입했다 돌아올 때 카테고리 트리와 미분류 회사코드 접기/펼치기 상태가 초기화되는 문제를 수정한다. expandedGroups, expandedCompanyCodes를 sessionStorage에 저장하여 같은 탭 세션 내에서 상태가 유지되도록 변경.
This commit is contained in:
parent
cc44f714c6
commit
e5abd93600
|
|
@ -471,7 +471,15 @@ export function PopCategoryTree({
|
|||
// 상태 관리
|
||||
const [groups, setGroups] = useState<PopScreenGroup[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [expandedGroups, setExpandedGroups] = useState<Set<number>>(new Set());
|
||||
const [expandedGroups, setExpandedGroups] = useState<Set<number>>(() => {
|
||||
if (typeof window === "undefined") return new Set();
|
||||
try {
|
||||
const saved = sessionStorage.getItem("pop-tree-expanded-groups");
|
||||
return saved ? new Set(JSON.parse(saved) as number[]) : new Set();
|
||||
} catch {
|
||||
return new Set();
|
||||
}
|
||||
});
|
||||
const [selectedGroupId, setSelectedGroupId] = useState<number | null>(null);
|
||||
|
||||
// 그룹 모달 상태
|
||||
|
|
@ -500,7 +508,15 @@ export function PopCategoryTree({
|
|||
const [moveSearchTerm, setMoveSearchTerm] = useState("");
|
||||
|
||||
// 미분류 회사코드별 접기/펼치기
|
||||
const [expandedCompanyCodes, setExpandedCompanyCodes] = useState<Set<string>>(new Set());
|
||||
const [expandedCompanyCodes, setExpandedCompanyCodes] = useState<Set<string>>(() => {
|
||||
if (typeof window === "undefined") return new Set();
|
||||
try {
|
||||
const saved = sessionStorage.getItem("pop-tree-expanded-companies");
|
||||
return saved ? new Set(JSON.parse(saved) as string[]) : new Set();
|
||||
} catch {
|
||||
return new Set();
|
||||
}
|
||||
});
|
||||
|
||||
// 화면 맵 생성 (screen_id로 빠르게 조회)
|
||||
const screensMap = useMemo(() => {
|
||||
|
|
@ -544,6 +560,9 @@ export function PopCategoryTree({
|
|||
} else {
|
||||
next.add(groupId);
|
||||
}
|
||||
try {
|
||||
sessionStorage.setItem("pop-tree-expanded-groups", JSON.stringify([...next]));
|
||||
} catch { /* noop */ }
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
|
@ -1013,6 +1032,9 @@ export function PopCategoryTree({
|
|||
} else {
|
||||
next.add(code);
|
||||
}
|
||||
try {
|
||||
sessionStorage.setItem("pop-tree-expanded-companies", JSON.stringify([...next]));
|
||||
} catch { /* noop */ }
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue