Nested work item TOC entries are oddly reorderable via drag-and-drop

Every TOC entry below is draggable! (if you can edit this issue)

1. Summary

When a work item description includes a table of contents, its nested entries get drag handles and can be reordered via drag-and-drop1.

This looks like the same family of bug as Work item footnotes are oddly reorderable via d... (#602896 - closed), which was fixed by Prevent footnote from being reorderable in work... (!240523 - merged).

2. Steps to reproduce

Create a work item with a description like:

[[_TOC_]]

# Heading
## Heading A

This is A.

## Heading B

This is B.

## Heading C

This is C.

Then hover over the second-level TOC entries and drag one of them.

This issue itself has the same structure, so if you can edit it, you can reproduce the bug right here in the TOC above.

3. What is the current bug behavior?

Hovering over the TOC reveals drag handles to the left of each nested entry, and you can drag and drop to reorder them:

issue-toc-reorderable

Oddly enough, the headings themselves don't move, so the TOC no longer reflects the actual document order. Reloading the page restores the original order.

On drop, the following error is thrown in the browser console:

Uncaught TypeError: Cannot read properties of undefined (reading 'split')

4. What is the expected correct behavior?

TOC entries don't get drag handles and can't be reordered.

Alternatively, dragging a TOC entry could move the corresponding section within the description.

5. Output of checks

This bug happens on GitLab.com

  1. https://docs.gitlab.com/user/project/issues/managing_issues/#description-lists-and-task-lists ↩

Edited by 🤖 GitLab Bot 🤖