적용 버튼 눌렀을 때 초기 위치, 초기 크기로 되돌아가는 에러 해결

This commit is contained in:
dohyeons 2025-10-23 12:54:46 +09:00
parent 1b6d63bf74
commit a4473eee33
1 changed files with 14 additions and 5 deletions

View File

@ -392,12 +392,21 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
// 사이드바 적용
const handleApplySidebar = useCallback(
(updatedElement: DashboardElement) => {
updateElement(updatedElement.id, updatedElement);
// 사이드바는 열린 채로 유지하여 연속 수정 가능
// 단, sidebarElement도 업데이트해서 최신 상태 반영
setSidebarElement(updatedElement);
// 현재 요소의 최신 상태를 가져와서 position과 size는 유지
const currentElement = elements.find((el) => el.id === updatedElement.id);
if (currentElement) {
// position과 size는 현재 상태 유지, 나머지만 업데이트
const finalElement = {
...updatedElement,
position: currentElement.position,
size: currentElement.size,
};
updateElement(finalElement.id, finalElement);
// 사이드바도 최신 상태로 업데이트
setSidebarElement(finalElement);
}
},
[updateElement],
[elements, updateElement],
);
// 레이아웃 저장