Skip to content

Nest a list item with Tab in a composer, and take it out with Shift+Tab - #4871

Merged
max-sixty merged 3 commits into
mainfrom
textbox-markdown-explore
Oct 31, 2026
Merged

max-sixty merged 3 commits into
mainfrom
textbox-markdown-explore

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

In a composer, Tab now nests the list item the caret is in under the item above, and ⇧Tab takes it out a level. Today Tab leaves the field, so a nested item has to be typed as spaces. The maintainer chose this on the composer exploration page, after #4738.

Behaviour

  • - one ⇧⏎ ⇥ two gives - one\n - two. The nested marker stands where the words of the item above start: 2 columns under - , 3 under 1. . The preview draws the nested bullet as soon as Tab is pressed.
  • ⇧Tab moves the item to its parent's column, with the parent list's next marker. Items after it in its old list stay where they are, so they are now nested under it, as in Google Docs.
  • Numbered items: one that starts a new nested list becomes 1.; one that joins an existing nested list takes that list's next number. Task items keep their [ ]. Lines in a quote keep their >. An item's later lines and nested items move with it, and a selection spanning items moves them together. One press is one undo step.
  • Outside a list item, Tab and ⇧Tab move focus as before. Tab from the panel's field still opens Other responses.
  • At the edges: Tab on the first item of a list does nothing and keeps focus, as in Docs and Notion. ⇧Tab on a top-level item moves focus back, so a draft that is all list can still be left by keyboard.
  • Touch has no Tab. Typing the spaces still nests an item.

Where to look

  • browser/runtime/composing/field-editor.js: nestItems reads the list from the same markdown-it reading (placedMarkdownTokens) the preview and Shift+Enter use, so there is no second list parser. itemEnd is now shared with continueBlocks. The draft's reading also treats a last line holding only list markers as holding a word. Otherwise a new empty nested item would read, as CommonMark has it, as words of the paragraph above, and the preview would show a literal - until words were typed.
  • tests/words_watch.js: a Tab the page prevents now counts as a command key, as Shift+Enter does. Before this, a nest made right after typing was reported as words vanishing.
  • browser/runtime/keyboard/AGENTS.md and text-field.js say what Tab does in a field.

Testing

tests/runtime/list-nesting.test.mjs covers the source transformation. test_tab_nests_a_list_item_and_shift_tab_takes_it_out, in Chromium and Firefox, covers nest, un-nest, a quoted list, a numbered item, the first item, undo, the nested bullet with and without words, and focus leaving outside a list. Both new tests fail without the change. pnpm run test:runtime passes 720/720, and the focused Shift+Enter, list-bullet, fence and Return tests pass.

This was written by Claude Code on behalf of max-sixty

Tab in a list item of a `leaf-text` field now nests the item under the item
above it, its marker standing where that item's words start (2 columns under
`- `, 3 under `1. `), so the message renders it as a nested item. Shift+Tab
takes it out a level, into its parent's list in that list's marker. Ordered
and task items work the same, quotes keep their `>`, an item's later lines and
nested items move with it, and a selection spanning items moves them
together. One press is one undo step.

Where the caret is in no list item, Tab and Shift+Tab move focus as before
(Tab from the panel's field still opens Other responses). In a list, Tab on an
item with no item above (the first of its list) does nothing and keeps focus;
Shift+Tab on a top-level item moves focus back, so a draft that is all list
still lets focus out.

`nestItems` reads the list from the same placed markdown-it tokens the preview
and Shift+Enter use; `itemEnd` is now shared with `continueBlocks`. The draft's
reading also takes a last line holding only list markers as holding a word,
so a new empty nested item shows its nested bullet instead of reading, as
CommonMark does, as words of the paragraph above.

The test harness's words watch counted Tab as a key that only moves focus; a
Tab the page prevents now counts as a command key, like Shift+Enter.
leaf-agent
leaf-agent previously approved these changes Oct 31, 2026
# Conflicts:
#	dist/kernel/kernel.json
@max-sixty
max-sixty merged commit 33406b2 into main Oct 31, 2026
1 check passed
@max-sixty
max-sixty deleted the textbox-markdown-explore branch October 31, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants