NotionX / NotionX/react-notion-x
getListNumber() returns faulty indexes when there are different block types in-between numbered list blocks
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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