Skip to content

Commit de640fd

Browse files
committed
fix: 스태킹된 블록이 없는데도 블록 삭제 불가
1 parent 6b78a3f commit de640fd

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/utils/stackingRules.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,36 @@ export function canDeleteBlockWithStore(
160160
} {
161161
const stackingState = stackingStates.get(blockId);
162162

163+
console.log('🔍 삭제 검증:', {
164+
blockId,
165+
stackingState,
166+
hasState: !!stackingState,
167+
childBlockIds: stackingState?.childBlockIds
168+
});
169+
163170
// 스태킹 상태가 없거나 자식이 없으면 삭제 가능
164-
if (!stackingState || stackingState.childBlockIds.length === 0) {
171+
if (!stackingState || !stackingState.childBlockIds || stackingState.childBlockIds.length === 0) {
172+
console.log('✅ 삭제 가능 - 스택된 자식 블록 없음');
165173
return { canDelete: true };
166174
}
167175

168-
// 자식 블록들 찾기
176+
// 자식 블록들 찾기 (실제로 존재하는 블록만)
169177
const childBlocks = stackingState.childBlockIds
170178
.map((childId: string) => allBlocks.find(b => b.id === childId))
171179
.filter(Boolean);
172180

181+
console.log('🔍 자식 블록 검증:', {
182+
childIdsInState: stackingState.childBlockIds,
183+
actualChildBlocks: childBlocks.map((b: any) => ({ id: b.id, type: b.type }))
184+
});
185+
186+
// 실제 존재하는 자식 블록이 없으면 삭제 가능
187+
if (childBlocks.length === 0) {
188+
console.log('✅ 삭제 가능 - 자식 블록 ID는 있지만 실제 블록은 존재하지 않음 (stale state)');
189+
return { canDelete: true };
190+
}
191+
192+
console.log('❌ 삭제 불가 - 실제 스택된 블록 존재:', childBlocks.length);
173193
return {
174194
canDelete: false,
175195
reason: `이 블록 위에 ${childBlocks.length}개의 블록이 스택되어 있습니다.`,

0 commit comments

Comments
 (0)