diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index 0840dc2d..05a76e9b 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -108,15 +108,18 @@ export function useRoofAllocationSetting(id) { // 지붕재 오른쪽 마우스 클릭 후 단일로 지붕재 변경 필요한 경우 const handleSaveContext = () => { + const newRoofList = currentRoofList.map((roof, idx) => { + return { ...roof, index: idx } + }) setBasicSetting((prev) => { return { ...prev, - selectedRoofMaterial: currentRoofList.find((roof) => roof.selected), + selectedRoofMaterial: newRoofList.find((roof) => roof.selected), } }) - setRoofList(currentRoofList) - const selectedRoofMaterial = currentRoofList.find((roof) => roof.selected) + setRoofList(newRoofList) + const selectedRoofMaterial = newRoofList.find((roof) => roof.selected) setSurfaceShapePattern(currentObject, roofDisplay.column, false, selectedRoofMaterial) closeAll() } @@ -180,14 +183,18 @@ export function useRoofAllocationSetting(id) { canvas.remove(wallLine) }) + const newRoofList = currentRoofList.map((roof, idx) => { + return { ...roof, index: idx } + }) + setBasicSetting((prev) => { return { ...prev, - selectedRoofMaterial: currentRoofList.find((roof) => roof.selected), + selectedRoofMaterial: newRoofList.find((roof) => roof.selected), } }) - setRoofList(currentRoofList) + setRoofList(newRoofList) const roofs = canvas.getObjects().filter((obj) => obj.name === 'roof') diff --git a/src/store/settingAtom.js b/src/store/settingAtom.js index 1b837fdd..305bcb57 100644 --- a/src/store/settingAtom.js +++ b/src/store/settingAtom.js @@ -224,9 +224,7 @@ export const roofMaterialsAtom = atom({ export const selectedRoofMaterialSelector = selector({ key: 'selectedRoofMaterialSelector', get: ({ get }) => { - const addedRoofs = get(addedRoofsState) - - return addedRoofs.find((roof) => roof.selected) + return get(basicSettingState).selectedRoofMaterial }, })