NotionX / NotionX/react-notion-x

getListNumber() returns faulty indexes when there are different block types in-between numbered list blocks

Open
#338 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.4k
Forks
645
PR merge metrics
No merged PRs in 30d

Description

If you have the following in Notion:
⠀ 1. Apple
⠀ 2. Pear
⠀ [Image block]
⠀ 3. Banana

react-notion-x will render it as:
⠀ 1. Apple
⠀ 2. Pear
⠀ [Image block]
⠀ 1. Banana

I believe the issue comes from getListNumber():
https://github.com/NotionX/react-notion-x/blob/7a8179f12d94d755d89b0687b95f0646edeed79c/packages/react-notion-x/src/utils.ts#L49

Shouldn't this be something like this instead?

return (blockMap[blockId]?.value?.format?.list_start_index ?? 0) + group.indexOf(blockId) + 1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/react-notion-x/src/utils.ts at getListNumber(), using the mixed numbered-list and image-block example from the issue to reproduce the faulty index. Verify that numbering continues after intervening block types and run the relevant test suite to confirm the corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.