Skip to content

[Bug] Shift+Tab on a nested task list item puts a task item inside the parent bullet list #5341

Closed

Description

@Jocs

Description

Pressing Shift+Tab on a nested task list item moves it into the parent bullet list as a task item, instead of starting a new task list. The editor state ends up with a task-list-item directly inside a bullet-list (the state types only allow list-item there), and the rendered list mixes a plain bullet with checkbox items. After saving, the markdown no longer round-trips: reopening it (or toggling source code mode twice) splits the list in two.

No error is thrown.

Steps to Reproduce

  1. Open a document with:
    - a
      - [ ] b
  2. Click at the end of b and press Shift+Tab.
  3. Type z, press Enter, type n.
  4. Switch to source code mode, then back to the WYSIWYG editor, then to source code mode again.

Expected Behavior

The outdented item stays a task item (checkbox and checked state preserved), and the parent list is split around it, so the item lands in a new task list at the parent level:

before Shift+Tab:  bullet-list( list-item( "a", task-list( task-list-item("b") ) ) )
after Shift+Tab:   bullet-list( list-item("a") ), task-list( task-list-item("b") )

This is the structure muya's parser already builds for the saved markdown (- a\n- [ ] b reopens as bullet-list(a) followed by task-list(b)), so the document stays the same across a reopen / source-mode round trip.

Cases the fix should cover:

  • Items after the parent item (- a / - [ ] b / - c): split the outer list into bullet-list(a), task-list(b), bullet-list(c).
  • Task items after b in the nested list stay nested under b, as they do today.
  • The reverse case — a plain list item nested in a task list, outdented into the outer task list — splits the same way, into a new bullet list.
  • Open question: when the block right after the split point is already a task list, merge b into it (preferred) or keep two adjacent task lists.

Actual Behavior

  • After step 3 the editor shows one ul.mu-bullet-list holding mu-list-item (a) and two mu-task-list-item rows with checkboxes (bz, n).
  • The markdown is - a\n- [ ] bz\n- [ ] n.
  • After the source-mode round trip it becomes - a\n\n- [ ] bz\n- [ ] n: a and the task items are now two separate lists (a blank line is inserted).

Screenshots / Logs

State after Shift+Tab (from muya.editor.jsonState.getState()):

bullet-list( list-item(paragraph "a"), task-list-item(paragraph "b") )

Analysis: the UnindentType.INDENT branch of ParagraphContent._unindentListItem() (packages/muya/src/block/content/paragraphContent/index.ts) clones the task-list-item and inserts it next to the parent list-item inside the outer bullet-list, without converting the item type to match the target list. Found while reviewing #4913; the behaviour is the same on develop before and after that PR.

Reproduced in the built desktop app (Playwright + Electron) and in real Chrome against the muya e2e host.

Operating System

macOS

MarkText Version

develop @ a351c50 (the code involved is unchanged since v0.20.0-rc.2)

OS Version

macOS 27.0

Reproducibility

  • I can reliably reproduce this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bug🔭 area/muya🚧 needs triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions