diff --git a/frontend/src/components/atoms/BlockContent/BlockContent.tsx b/frontend/src/components/atoms/BlockContent/BlockContent.tsx index ff3b6b4..95a5c5a 100644 --- a/frontend/src/components/atoms/BlockContent/BlockContent.tsx +++ b/frontend/src/components/atoms/BlockContent/BlockContent.tsx @@ -88,17 +88,19 @@ function BlockContent(blockDTO: Block) { if (focusId === blockDTO.id) contentEditableRef.current.focus(); }, [focusId]); + const upperBlocks: Array = prevSiblings?.reverse(); + const isUpperBlockEqualToNumberList = (): boolean => { - if (prevSiblings.length) { - return prevSiblings[0].type === BlockType.NUMBERED_LIST; + if (upperBlocks.length) { + return upperBlocks[0].type === BlockType.NUMBERED_LIST; } return false; }; const cntOfUpperNumberListBlock = (): number => { let cnt = 0; - if (prevSiblings) { - for (const upperblock of prevSiblings) { + if (upperBlocks) { + for (const upperblock of upperBlocks) { if (upperblock.type !== BlockType.NUMBERED_LIST) break; cnt += 1; } diff --git a/frontend/src/hooks/useFamily.tsx b/frontend/src/hooks/useFamily.tsx index 37ddab0..2565777 100644 --- a/frontend/src/hooks/useFamily.tsx +++ b/frontend/src/hooks/useFamily.tsx @@ -27,7 +27,7 @@ const useFamily = (blockId: string): [BlockFamily, FamilyFunc] => { ); const prevSibling = siblings?.[blockIndex - 1]; const nextSibling = siblings?.[blockIndex + 1]; - const prevSiblings = siblings?.slice(0, blockIndex).reverse(); + const prevSiblings = siblings?.slice(0, blockIndex); const nextSiblings = siblings?.slice(blockIndex); const findLastDescendant = (targetBlock: Block) => {