Skip to content

[2.x] Continue lists when pressing Enter in the Markdown editor#4778

Merged
imorland merged 1 commit into
flarum:2.xfrom
karl-bullock:fix/ordered-list-continuation
Jul 7, 2026
Merged

[2.x] Continue lists when pressing Enter in the Markdown editor#4778
imorland merged 1 commit into
flarum:2.xfrom
karl-bullock:fix/ordered-list-continuation

Conversation

@karl-bullock

Copy link
Copy Markdown
Contributor

Fixes #4232

Changes proposed in this pull request

The Markdown editor never continued lists when pressing Enter — it just inserted a plain newline. So the only way to add a numbered item was to re-click the toolbar button, which always emits 1. for the current line. The result was that you couldn't build a 1./2./3. list by typing, which is what #4232 reports.

This adds list continuation to the editor's existing keyHandlers extender (the same place the bold/italic shortcuts live, so core stays generic). On a plain Enter inside a list item it now:

  • continues ordered lists, incrementing the number — 1. a2. 3. (also handles the 1) delimiter and 9 → 10);
  • continues unordered lists, repeating the bullet (-, *, +);
  • ends the list when Enter is pressed on an empty item;
  • preserves leading indentation;
  • ignores Ctrl/Cmd/Shift/Alt+Enter (submit / soft newline) and IME composition, and only acts on a collapsed selection.

This mirrors the list-continuation behaviour people expect from GitHub's editor and most Markdown editors.

Reviewers should focus on

  • extensions/markdown/js/src/common/index.tsx — the continueList handler and its registration. The dist changes are the rebuilt bundle.
  • Whether keyHandlers on BasicEditorDriver is the right home for this vs. core. I kept it in the markdown extension since list markers are Markdown syntax.

Confirmed

  • Frontend changes: tested in the latest Firefox and Chrome.
  • Translations added for any user-facing text — N/A (no new strings).
  • Backend changes — N/A.

Testing

Verified manually in a 2.0.0-rc.4 forum (with the rich-text editor disabled so the Markdown textarea editor is active): typing a numbered list and pressing Enter now produces 1., 2., 3.; unordered lists repeat the bullet; and pressing Enter on an empty item ends the list.

@karl-bullock karl-bullock requested a review from a team as a code owner June 22, 2026 22:13
@karl-bullock karl-bullock changed the title Continue lists when pressing Enter in the Markdown editor [2.x] Continue lists when pressing Enter in the Markdown editor Jun 22, 2026

@imorland imorland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't commit dist files with PRs. Can you please remove them, the bot will handle building these if/when a PR is merged

Pressing Enter inside a list item now inserts the next list marker instead
of a plain newline: ordered lists increment the number (1. -> 2. -> 3.) and
unordered lists repeat the bullet. Pressing Enter on an empty item ends the
list. Leading indentation is preserved, and the handler ignores modifier
combinations (Ctrl/Cmd/Shift/Alt+Enter) and IME composition.

Previously the only way to add a numbered item was to re-click the toolbar
button, which always produced "1.", so multi-item numbered lists were
effectively impossible.

Fixes flarum#4232
@karl-bullock karl-bullock force-pushed the fix/ordered-list-continuation branch from 661136a to ad7f741 Compare July 5, 2026 00:52
@karl-bullock

Copy link
Copy Markdown
Contributor Author

Done, I've dropped the dist files so the PR is just the source change now. Thanks for the review!

@imorland imorland added this to the 2.0.0-rc.5 milestone Jul 7, 2026
@imorland imorland merged commit f7af4f4 into flarum:2.x Jul 7, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Numbered List Not Working in Editor

2 participants