mdx-editor / mdx-editor/editor

[BUG] Numbered list with sub-list shows wrong numbers

Open
#515 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
3.7k
Forks
307
Avg merge
14h 22m
Merged PRs (30d)
5

Description

If you want to ask for support or request features, sponsor the project and contact me over email.

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • I have read the documentation and cannot find an answer.

Describe the bug
If you have the following numbered list, with a sub list:

1. one
   1. sub 1
   2. sub 2
2. two
3. three

once you go to view source and back to rich text mode, or if you load the editor with this markdown as the current value - the numbered list after the sub list will be wrong, showing 3 instead of 2

Reproduction
https://codesandbox.io/p/sandbox/mdx-editor-base-forked-vksdyj?file=%2Fsrc%2FApp.tsx

To Reproduce
Steps to reproduce the behavior:

  1. add the above markdown
  2. switch to source and back to rich text
  3. bullet 2 is now 3

Expected behavior
After a sub-list, bullets should continue normal numbering

Screenshots
On load, or after edit:
image

After switching to source and back:
image

Desktop (please complete the following information):

  • OS: Windows
  • Browser Edge

Additional context
This happens every time after a nested sub list, the next number on the higher level will jump to the next.

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 with the App.tsx reproduction linked in the CodeSandbox and trace the source-to-rich-text conversion for the nested numbered-list example. Verify the behavior when switching between source and rich text, and consider the work done when the top-level list continues with 2 after the sub-list rather than 3.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.