From cdadf8588aa53266d7edd60d5155328479fc3ac1 Mon Sep 17 00:00:00 2001 From: sanabriageorge Date: Thu, 2 Apr 2026 08:06:25 -0400 Subject: [PATCH] fix(core): nested numbered list order (#14764) ## The Fix ## Fixes #13396. The issue happened because 'doc.getPrev(model)' returns previous node based in document order instead of previous sibling within list level. This caused nested list items to inherit the numbering from their parent rather than restarting. The fix ensures that numbering is calculated relative to correct list context. ## Video Demonstration ## ### Before ### https://github.com/user-attachments/assets/9523209a-93d9-4984-aa9e-149ac1941036 ### After ### https://github.com/user-attachments/assets/ff28b166-3572-4536-9893-0ab5c05c8d9f ## Summary by CodeRabbit * **Bug Fixes** * Enhanced numbered list ordering logic for improved list handling. * **Chores** * Updated environment configuration template with active sample values for database connectivity, caching services, AI integrations, and email delivery settings. --- blocksuite/affine/blocks/list/src/commands/utils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blocksuite/affine/blocks/list/src/commands/utils.ts b/blocksuite/affine/blocks/list/src/commands/utils.ts index d6975e0510..790ed7db5a 100644 --- a/blocksuite/affine/blocks/list/src/commands/utils.ts +++ b/blocksuite/affine/blocks/list/src/commands/utils.ts @@ -30,7 +30,11 @@ export function correctNumberedListsOrderToPrev( const fn = () => { // step 1 - const previousSibling = doc.getPrev(model); + const parent = doc.getParent(model); + if (!parent) return; + const index = parent.children.indexOf(model); + const previousSibling = index > 0 ? parent.children[index - 1] : null; + if ( previousSibling && matchModels(previousSibling, [ListBlockModel]) &&