← Back to Pull requests

[lexical-list] Bug Fix: Write `li.value` only where the browser's count differs, so Enter near the top of a long list is not quadratic #9958

Merged
emilyhorsman merged 37 files (2746 lines) on Nov 23, 2026 11:36 UTC
View on GitHub
emilyhorsman emilyhorsman commented on Nov 20, 2026 17:33 UTC
Author

Description

At the moment ListItemNode.updateDOM (through createDOM) runs dom.value = this.__value on every list item of every list type, bullet and check lists included. Inserting an item renumbers every item after it (updateChildrenListItemValue), so each later item is dirty and reconciled, and each one writes li.value. In our Chromium profiles, each of those writes makes the browser recompute the list's item ordinals, so an Enter near the top of an n-item list costs O(n²).

In the playground on main (headless Chromium, a pasted 4,000-item numbered list), one Enter at the end of item 1 takes:

  • 1.48–1.52 s;

  • 6.2–6.4 s with the CPU throttled 4×.
  • This PR makes an item write value only where its number differs from the number the browser draws from the list's own count: the <ol start> for the first item, otherwise the previous item's number plus one. Every item still shows its __value.

  • Bullet and check items never carry a value. Any value already on one is removed.

  • Most numbered items need no value at all. The item after a nested list does get one: Lexical doesn't count the nested list's wrapper item, but the browser does.

  • Unchanged: the model, serialization and exportDOM. Exported and copied HTML still writes value on every item, so pasted lists number as before.

  • Correctness: an item's decision depends only on its own __value, its previous sibling's __value, and the list's type and start. Every renumbered item is dirty and reconciled, and inserting, removing or moving a sibling marks its neighbours dirty. The one remaining case is a previous item renumbered alone: an item that only wraps a nested list keeps the number of the item after it, so an insert above it renumbers the wrapper and not that item. For that, updateDOM re-decides the next item's value whenever an item's __value changes. This also covers remote updates that @lexical/yjs applies without the list transforms. So the number the browser shows always equals __value.
  • Playground, same setup, with this change: the same Enter takes 143–151 ms at 1× and 599–632 ms at 4×. The markers Chromium draws (read from the accessibility tree) are identical before and after for:

  • a plain list;

  • a list with start;

  • items after a nested list, including after an Enter above it;

  • an item with text before its nested list.
  • This changes the rendered editor DOM.

  • No value on most items: live numbered list items no longer carry value where the browser already shows the right number, and bullet and check items carry none.

  • Code that reads li.value off the editor's DOM, rather than the model's getValue(), reads 0 for those items.

  • CSS: rules that select li[value] or read attr(value) (for example custom multi-level numbering) no longer match most items.

  • Native copy: copying the live DOM natively, without Lexical's copy handler (which uses exportDOM), loses the numbers of a mid-list selection, since those items no longer carry value.

  • Reversed lists and hidden items: ListNode has no reversed support. A subclass or theme that adds <ol reversed> would need its own rule, since the browser counts down there. An item hidden with display: none is still counted by Lexical but not by the browser, so the items after it draw one lower.
  • Updated tests:

  • Expected innerHTML changed. value="N" is removed from live <li>s, except where the item still needs it (after a nested list):

  • - unit: lexical-list LexicalListItemNode.test.ts and LexicalListNode.test.ts; lexical-utils LexicalEventHelpers.test.tsx; lexical HTMLCopyAndPaste.test.ts, LexicalListPlugin.test.tsx, LexicalEditor.test.tsx and LexicalTabNode.test.tsx; lexical-selection LexicalSelection.test.tsx;
    - playground e2e:
    - List, Indentation, Markdown, CharacterLimit, File, HorizontalRule, Links and ShadowDOM specs;
    - in ListsCopyAndPaste, ListsHTMLCopyAndPaste and Collaboration, only the assertHTML expectations, so pasted inputs keep their values;
    - the regressions 3433-merge-markdown-lists and 7246-delete-character-backward-list.
  • @lexical/y checks (__tests__/catalog/bind.ts, C1ReadEqualsFresh, C1Busy, ListValuesAfterRead):

  • - These compared each rendered li.value with the model's values. They now compare the number each numbered item shows (its value attribute, else the list's own count) with the model.
    - They also assert that bullet and check items carry no value.
    - They still fail when a rendered number differs from the model; see the mutation check below.
  • Browser-mode unit tests (MarkdownShortcuts, ListKeyboard, ListsHTMLCopyAndPaste, LinksHTMLCopyAndPaste): value="N" is removed from live <li>s in the expected HTML, as in the jsdom tests. No matcher is loosened.

  • New:

  • - packages/lexical-list/src/__tests__/unit/ListItemValueAttribute.test.ts: the attribute rule, plus exportDOM writing value before the theme classes on every item of every list type.
    - Drawn numbers vs the model, across 24 edits (packages/lexical-list/src/__tests__/unit/listEditCases.ts): wrappers, a start change, a split, a merge, a move, indent and outdent, list type changes and pasted HTML. Each case runs after the edit, its undo and its redo, in three places:
    - jsdom (ListItemDrawnNumbers.test.ts);
    - a collaborating peer, collab v1 and v2, including concurrent edits on both clients and a remote renumber while the peer has its own pending edit (packages/lexical-react/src/__tests__/unit/CollaborationListNumbers.test.ts);
    - Chromium, reading each marker from the accessibility tree (packages/lexical-list/src/__tests__/browser/ListItemDrawnNumbers.test.ts).

    Changeset

    .changeset/list-item-value-attribute.md:

    ---
    '@lexical/list': patch
    ---
    
    [fix] Stop writing `value` on every list item, which made Enter near the top of a long list quadratic in Chromium
    
    Verify: numbered lists show the same numbers as before (including lists with a `start`, nested lists and the item after them), bullet and check items carry no `value` attribute, and copied or exported HTML still writes `value` on every item, in the same place as before.
    
    Live list items in the editor no longer carry `value` where the browser's own count shows their number: reading `li.value` from the editor's DOM gives `0` for them, and `li[value]` or `attr(value)` CSS no longer matches. Read the number with `ListItemNode.getValue()`, or from `exportDOM`. Because the browser counts the items it draws, an item hidden with `display: none` (or a list drawn `reversed`) shifts the numbers after it.
    

    pnpm run check-changesets passes.

    Test plan

    Before

    $ pnpm exec vitest run --project unit packages/lexical-list/src/__tests__/unit/ListItemValueAttribute.test.ts
         × a number list writes no value where the browser count matches
         × a list with a start relies on <ol start>
         × inserting an item at the top writes no value on any item
         × the item after a nested list keeps its number
         × removing the nested list clears the value it needed
         × bullet and check items never carry a value
         ✓ exportDOM keeps every item value
    AssertionError: expected [ '1', '2', '3' ] to deeply equal [ null, null, null ]
    AssertionError: expected [ '1', '2', '3', '1', '2', '3' ] to deeply equal [ null, null, null, null, null, '3' ]
          Tests  6 failed | 1 passed (7)
    
    Playground, 4,000-item numbered list, Enter at the end of item 1 (keydown -> next paint), 3 runs:
      1x CPU: 1484, 1477, 1519 ms    4x CPU: 6161, 6322, 6378 ms
    

    Regression case (from review): a numbered list a, p (text, then a nested list x), n, m. Delete p's text so the item only wraps the nested list, then insert b after a. The model is a 1, b 2, (wrapper) 3, n 3, m 4.

    $ pnpm exec vitest run --project unit packages/lexical-list/src/__tests__/unit/ListItemDrawnNumbers.test.ts -t 'item becomes a wrapper'
    Before (this PR's first commit):
         × item becomes a wrapper, then an item is inserted above it, then undo and redo
    AssertionError: after the edit: expected [ '1 a', '2 b', '4 n', '5 m', …(2) ] to deeply equal [ '1 a', '2 b', '3 n', '4 m', …(2) ]
    After:
         ✓ item becomes a wrapper, then an item is inserted above it, then undo and redo
    

    The same case also runs on a collaborating peer (collab v1 and v2) and in Chromium's accessibility tree. With the updateDOM change reverted, those fail too: the peer and the browser both draw 4. n and 5. m. With it, all of them pass. On main, every case in these files passes (main writes value on every item).

    After

    $ pnpm exec vitest run --project unit packages/lexical-list/src/__tests__/unit/ListItemValueAttribute.test.ts
     ✓ |unit| packages/lexical-list/src/__tests__/unit/ListItemValueAttribute.test.ts (7 tests)
          Tests  7 passed (7)
    
    $ pnpm run test-unit
          Tests  40715 passed | 174 skipped (40892)
          (7 `lexical-devtools` test files fail to load on this machine because its `wxt prepare` install step crashes here; this PR changes no `lexical-devtools` file)
    
    $ pnpm run test-browser    # Chromium
          Tests  1159 passed | 2 skipped (1161)
    
    $ pnpm run test-e2e-chromium <the 13 specs above that contain <li> expectations>
      8 skipped
      156 passed (1.2m)
    
    $ pnpm run tsc       # clean
    $ pnpm run flow      # Found 0 errors
    
    Playground, same list and keys, 3 runs:
      1x CPU: 151, 148, 143 ms       4x CPU: 632, 620, 599 ms
    Markers drawn by Chromium (accessibility tree), before and after:
      plain 1. 2. 3. | start=4 4. 5. 6. | after a nested list, with an Enter above it 1. 2. 3. 4. 5. (A. B.) | text then nested list 1. 2. 3. (A.)
    

    Mutation check: the updated @lexical/y checks still catch a wrong rendered number.

  • Never writing value: C1ReadEqualsFresh fails with rendered numbers [3,4,5,1,2,6,…] != [3,4,5,1,2,5,…] (the item after a nested list), and the new unit test fails.

  • Writing value on bullet items: C1ReadEqualsFresh fails with bullet or check items carry a value: ["1","2","3",…], and the new unit test fails.
  • Not run: Firefox and WebKit (e2e and browser-mode unit tests), the collab and prod-build e2e variants, and the full e2e suite beyond the 13 specs above. The browser-mode unit suite (pnpm run test-browser) ran in Chromium: 1,159 passed, 2 skipped.

    Diff: 2746 lines (+1978 / -768) across 37 files Reviewer: potatowagon Review duration: 3962m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.72) × (1 − Review Confidence (0.73)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.72 · 2746 lines diff across 37 files
    0.72
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.49 · 5 substantive comment(s)
    0.49
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    73%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    16 items
    vercel[bot] vercel[bot] commented on Nov 20, 2026 17:33 UTC
    Bot

    [vc]: #IBYkxFNOjqBq7f6kJjKytShXSmoFj75ULrWdmCCvO9A=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJsZXhpY2FsIiwicHJvamVjdElkIjoicHJqX01SYU1PMzFlRklrWTYxU0JxcVBEUjJPank4cVAiLCJ2MCI6ZmFsc2UsInJvb3REaXJlY3RvcnkiOiJwYWNrYWdlcy9sZXhpY2FsLXdlYnNpdGUiLCJpbnNwZWN0b3JVcmwiOiJodHRwczovL3ZlcmNlbC5jb20vZmJvcGVuc291cmNlL2xleGljYWwvNTRjRFgxdUhlNHRweVhwMVhQUU5IUVcxYjYzeCIsInByZXZpZXdVcmwiOiJsZXhpY2FsLWdpdC1lbWlseWhvcnNtYW4tbGlzdC1pdGVtLXZhbHVlLWRvbS1mYm9wZW5zb3VyY2UudmVyY2VsLmFwcCIsIm5leHRDb21taXRTdGF0dXMiOiJERVBMT1lFRCJ9LHsibmFtZSI6ImxleGljYWwtcGxheWdyb3VuZCIsInByb2plY3RJZCI6InByal9lYTgydkxqNjg0WHpTUmRlTzdKU2QwUU5rYXdzIiwidjAiOmZhbHNlLCJyb290RGlyZWN0b3J5IjoicGFja2FnZXMvbGV4aWNhbC1wbGF5Z3JvdW5kIiwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL2Zib3BlbnNvdXJjZS9sZXhpY2FsLXBsYXlncm91bmQvRkVEdGRpc255VHFjamhrREJFbzgyWmlCTFdaRCIsInByZXZpZXdVcmwiOiJsZXhpY2FsLXBsYXlncm91bmQtZ2l0LWVtaWx5aG9yc21hbi1saXN0LWl0LWNmMTJiNi1mYm9wZW5zb3VyY2UudmVyY2VsLmFwcCIsIm5leHRDb21taXRTdGF0dXMiOiJERVBMT1lFRCJ9XSwicmVxdWVzdFJldmlld1VybCI6Imh0dHBzOi8vdmVyY2VsLmNvbS92ZXJjZWwtYWdlbnQvcmVxdWVzdC1yZXZpZXc/b3duZXI9bWV0YSZyZXBvPWxleGljYWwmcHI9OTk1OCJ9
    The latest updates on your projects. Learn more about Vercel for GitHub.

    | Project | Deployment | Actions | Updated |
    | :--- | :----- | :------ | :------ |
    | <a href="https://vercel.com/fbopensource/lexical"><sup><img src="https://vercel.com/api/www/avatar?projectId=prj_MRaMO31eFIkY61SBqqPDR2Ojy8qP&teamId=team_QNIQyH5DJlqUjeCckcCcBEjE&s=32" width="16" height="16" align="middle" alt="" /></sup></a> lexical | !Ready Ready | Preview | <relative-time datetime="2026-11-23T02:45:14.682Z">Nov 23, 2026 2:45am UTC</relative-time> |
    | <a href="https://vercel.com/fbopensource/lexical-playground"><sup><img src="https://vercel.com/api/www/avatar?projectId=prj_ea82vLj684XzSRdeO7JSd0QNkaws&teamId=team_QNIQyH5DJlqUjeCckcCcBEjE&s=32" width="16" height="16" align="middle" alt="" /></sup></a> lexical-playground | !Ready Ready | Preview | <relative-time datetime="2026-11-23T02:45:14.683Z">Nov 23, 2026 2:45am UTC</relative-time> |

    <a href="https://vercel.com/vercel-agent/request-review?owner=meta&repo=lexical&pr=9958" rel="noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://agents-vade-review.vercel.sh/request-review-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://agents-vade-review.vercel.sh/request-review-light.svg"><img src="https://agents-vade-review.vercel.sh/request-review-light.svg" alt="Request Review"></picture></a>

    rootnode-bot[bot] rootnode-bot[bot] commented on Nov 20, 2026 17:33 UTC
    Bot

    AI review status for this pull request.

    | Review status | Updated |
    | :--- | :--- |
    | 🟢 Reviewed (for maintainers only) | <relative-time datetime="2026-11-23T03:09:18Z">Nov 23, 2026, 3:09 AM UTC</relative-time> |

    <!-- codebunny-status:1 r=318341089 p=9958 rv=2 -->

    pkg-pr-new[bot] pkg-pr-new[bot] commented on Nov 20, 2026 17:36 UTC
    Bot

    <details><summary><b>lexical</b></summary><p>

      npm i https://pkg.pr.new/lexical@9958
      


    </p></details>

    <details><summary><b>@lexical/a11y</b></summary><p>

      npm i https://pkg.pr.new/@lexical/a11y@9958
      


    </p></details>

    <details><summary><b>@lexical/clipboard</b></summary><p>

      npm i https://pkg.pr.new/@lexical/clipboard@9958
      


    </p></details>

    <details><summary><b>@lexical/code</b></summary><p>

      npm i https://pkg.pr.new/@lexical/code@9958
      


    </p></details>

    <details><summary><b>@lexical/code-core</b></summary><p>

      npm i https://pkg.pr.new/@lexical/code-core@9958
      


    </p></details>

    <details><summary><b>@lexical/code-prism</b></summary><p>

      npm i https://pkg.pr.new/@lexical/code-prism@9958
      


    </p></details>

    <details><summary><b>@lexical/code-shiki</b></summary><p>

      npm i https://pkg.pr.new/@lexical/code-shiki@9958
      


    </p></details>

    <details><summary><b>@lexical/compiler</b></summary><p>

      npm i https://pkg.pr.new/@lexical/compiler@9958
      


    </p></details>

    <details><summary><b>@lexical/devtools-core</b></summary><p>

      npm i https://pkg.pr.new/@lexical/devtools-core@9958
      


    </p></details>

    <details><summary><b>@lexical/dragon</b></summary><p>

      npm i https://pkg.pr.new/@lexical/dragon@9958
      


    </p></details>

    <details><summary><b>@lexical/eslint-plugin</b></summary><p>

      npm i https://pkg.pr.new/@lexical/eslint-plugin@9958
      


    </p></details>

    <details><summary><b>@lexical/extension</b></summary><p>

      npm i https://pkg.pr.new/@lexical/extension@9958
      


    </p></details>

    <details><summary><b>@lexical/fast-check</b></summary><p>

      npm i https://pkg.pr.new/@lexical/fast-check@9958
      


    </p></details>

    <details><summary><b>@lexical/file</b></summary><p>

      npm i https://pkg.pr.new/@lexical/file@9958
      


    </p></details>

    <details><summary><b>@lexical/hashtag</b></summary><p>

      npm i https://pkg.pr.new/@lexical/hashtag@9958
      


    </p></details>

    <details><summary><b>@lexical/headless</b></summary><p>

      npm i https://pkg.pr.new/@lexical/headless@9958
      


    </p></details>

    <details><summary><b>@lexical/history</b></summary><p>

      npm i https://pkg.pr.new/@lexical/history@9958
      


    </p></details>

    <details><summary><b>@lexical/html</b></summary><p>

      npm i https://pkg.pr.new/@lexical/html@9958
      


    </p></details>

    <details><summary><b>@lexical/internal</b></summary><p>

      npm i https://pkg.pr.new/@lexical/internal@9958
      


    </p></details>

    <details><summary><b>@lexical/link</b></summary><p>

      npm i https://pkg.pr.new/@lexical/link@9958
      


    </p></details>

    <details><summary><b>@lexical/list</b></summary><p>

      npm i https://pkg.pr.new/@lexical/list@9958
      


    </p></details>

    <details><summary><b>@lexical/mark</b></summary><p>

      npm i https://pkg.pr.new/@lexical/mark@9958
      


    </p></details>

    <details><summary><b>@lexical/markdown</b></summary><p>

      npm i https://pkg.pr.new/@lexical/markdown@9958
      


    </p></details>

    <details><summary><b>@lexical/mdast</b></summary><p>

      npm i https://pkg.pr.new/@lexical/mdast@9958
      


    </p></details>

    <details><summary><b>@lexical/offset</b></summary><p>

      npm i https://pkg.pr.new/@lexical/offset@9958
      


    </p></details>

    <details><summary><b>@lexical/overflow</b></summary><p>

      npm i https://pkg.pr.new/@lexical/overflow@9958
      


    </p></details>

    <details><summary><b>@lexical/plain-text</b></summary><p>

      npm i https://pkg.pr.new/@lexical/plain-text@9958
      


    </p></details>

    <details><summary><b>@lexical/react</b></summary><p>

      npm i https://pkg.pr.new/@lexical/react@9958
      


    </p></details>

    <details><summary><b>@lexical/rich-text</b></summary><p>

      npm i https://pkg.pr.new/@lexical/rich-text@9958
      


    </p></details>

    <details><summary><b>@lexical/selection</b></summary><p>

      npm i https://pkg.pr.new/@lexical/selection@9958
      


    </p></details>

    <details><summary><b>@lexical/table</b></summary><p>

      npm i https://pkg.pr.new/@lexical/table@9958
      


    </p></details>

    <details><summary><b>@lexical/tailwind</b></summary><p>

      npm i https://pkg.pr.new/@lexical/tailwind@9958
      


    </p></details>

    <details><summary><b>@lexical/text</b></summary><p>

      npm i https://pkg.pr.new/@lexical/text@9958
      


    </p></details>

    <details><summary><b>@lexical/utils</b></summary><p>

      npm i https://pkg.pr.new/@lexical/utils@9958
      


    </p></details>

    <details><summary><b>@lexical/y</b></summary><p>

      npm i https://pkg.pr.new/@lexical/y@9958
      


    </p></details>

    <details><summary><b>@lexical/yjs</b></summary><p>

      npm i https://pkg.pr.new/@lexical/yjs@9958
      


    </p></details>

    _commit: <a href="https://github.com/meta/lexical/runs/137455101733"><code>b3f345f</code></a>_

    rootnode-bot[bot] rootnode-bot[bot] commented on code on Nov 20, 2026 18:10 UTC
    Code Review
    packages/lexical-list/src/LexicalListItemNode.ts:1
    @@ -962,3 +964,31 @@ export function $isListItemNode(
     ): node is ListItemNode {
       return node instanceof ListItemNode;
     }
    +
    +/**
    + * Writes `li.value` only where the item's number differs from the one the
    + * browser draws from the list's own count: the `<ol start>` for the first
    + * item, otherwise the previous item's number plus one. Every item still shows
    + * its `__value`; bullet and check items never carry a `value`.
    + *
    + * Setting `HTMLLIElement.value` invalidates the whole list's ordinal cache in
    + * Blink, and inserting an item renumbers (and reconciles) every item after it,
    + * so writing it on every item made an insert near the top of an n-item list
    + * O(n^2).
    + */
    +function $updateListItemValueDOM(dom: HTMLLIElement, node: ListItemNode): void {
    +  const parent = node.getParent();
    +  if ($isListNode(parent) && parent.getListType() === 'number') {
    +    const prev = node.getPreviousSibling();
    +    const shown = $isListItemNode(prev)
    +      ? prev.getValue() + 1
    +      : parent.getStart();

    This number depends on the previous item's __value, but this function only runs when this item is reconciled. If the previous item becomes a wrapper (its text before the nested list is deleted) and an item is later inserted above it, updateChildrenListItemValue bumps the wrapper's value and leaves this item's unchanged, so this item is never reconciled and the browser draws it (and every later item) one too high. Repro: number list a, p + nested list, n, m; Backspace after p, then Enter after a: main draws 3. n, this branch 4. n. Marking the next sibling dirty when updateChildrenListItemValue changes a value fixes it locally; @lexical/yjs peers apply remote values with skipTransforms: true, so a reconcile-time check would cover them too.

    rootnode-bot[bot] rootnode-bot[bot] commented on code on Nov 20, 2026 18:10 UTC
    Code Review
    packages/lexical-list/src/LexicalListItemNode.ts:1
    @@ -336,6 +336,8 @@ export class ListItemNode extends ElementNode {
     
       exportDOM(editor: LexicalEditor): DOMExportOutput {
         const element = this.createDOM(editor._config);
    +    // Exported HTML keeps every item's value, so pasted lists number as before.
    +    (element as HTMLLIElement).value = this.__value;

    Optional: because value is now set after createDOM has added the theme classes, exported HTML with a list item class changes from <li value="1" class="..."> to <li class="..." value="1">. Same numbers, but not byte-for-byte the same output the description calls unchanged; snapshot tests of exported HTML may notice.

    rootnode-bot[bot] rootnode-bot[bot] commented on code on Nov 20, 2026 18:10 UTC
    Code Review
    .changeset/list-item-value-attribute.md:1
    @@ -0,0 +1,7 @@
    +---
    +'@lexical/list': patch
    +---
    +
    +[fix] Stop writing `value` on every list item, which made Enter near the top of a long list quadratic in Chromium
    +
    +Verify: numbered lists show the same numbers as before (including lists with a `start`, nested lists and the item after them), bullet and check items carry no `value` attribute, and copied or exported HTML still writes `value` on every item.

    Optional: the changelog takes only this file (.changeset/README.md), so consider adding that live items no longer carry value (li.value read from the editor is 0; li[value] and attr(value) CSS stop matching; use ListItemNode.getValue() or exportDOM), and that items hidden with display: none shift the numbers after them, next to the reversed caveat from the description.

    rootnode-bot[bot] rootnode-bot[bot] requested changes on Nov 20, 2026 18:10 UTC
    Changes Requested Reviewer

    Thanks for the careful write-up. The approach is sound, the speedup on long numbered lists is clear, and plain, nested, start and bullet/check lists still draw the same markers as before. Two things need to change before this can merge.

    1. An item can keep a stale (missing) value and show the wrong number (packages/lexical-list/src/LexicalListItemNode.ts:979-993)

    $updateListItemValueDOM decides an item's value from its previous sibling's __value, but it only runs when the item itself is reconciled. The description's correctness argument misses one case. The previous item turns into a wrapper (its first child becomes the nested list), and later its value goes up by one while the next item's value stays the same. updateChildrenListItemValue then calls setValue only on the wrapper, so the next item keeps a DOM computed for its old neighbour.

    Steps, on a number list a, p (text, then a nested list), n, m: Backspace after p, then Enter at the end of a and type b. The model is a 1, b 2, (wrapper) 3, n 3, m 4. main draws 3. n and 4. m; this branch draws 4. n and 5. m, and the rest of the list stays off by one until something renumbers it. The list code keeps items that hold text beside a nested list (INTERNAL_$liftsFromStructure, $outdentFromItemWithContent), and the description lists that shape among the checked cases.

    This test passes on main and fails on this branch:

    test('the item after a new wrapper keeps its number', async () => {
      const {editor} = testEnv;
      await editor.update(() => {
        const p = $createListItemNode().append(
          $createTextNode('p'),
          $createListNode('number').append($item('x')),
        );
        $getRoot().append(
          $createListNode('number').append($item('a'), p, $item('n'), $item('m')),
        );
      });
      await editor.update(() => {
        // Delete "p": the item now only wraps the nested list.
        const list = $getRoot().getFirstChildOrThrow() as ListNode;
        (list.getChildAtIndex(1) as ListItemNode).getFirstChildOrThrow().remove();
      });
      await editor.update(() => {
        // Enter at the end of "a".
        const list = $getRoot().getFirstChildOrThrow() as ListNode;
        list.getFirstChildOrThrow().insertAfter($item('b'));
      });
      // a, b, (wrapper 3), n 3, m 4: without a value, n is drawn as 4.
      const items = editor.getRootElement()!.firstElementChild!.children;
      expect(items[3].getAttribute('value')).toBe('3');
    });
    

    Marking the next sibling dirty in updateChildrenListItemValue whenever it changes an item's value makes that pass and keeps the @lexical/list unit tests green. Remote updates in @lexical/yjs are applied with skipTransforms: true (packages/lexical-yjs/src/SyncEditorStates.ts), though, so a receiving peer would not run that transform. A check at reconcile time would cover peers too. Please add the case as a regression test, with its Before and After output in the Test plan as AGENTS.md asks.

    2. The browser test suite fails on stale expectations

    core-tests / browser fails 20 tests that still expect value="N" on live items: packages/lexical-markdown/src/__tests__/browser/MarkdownShortcuts.test.ts and, under packages/lexical-playground/src/__tests__/browser/, ListsHTMLCopyAndPaste.test.ts, ListKeyboard.test.ts and LinksHTMLCopyAndPaste.test.ts. They need the same update as the unit and e2e specs.

    Optional, non-blocking

  • Changeset: the changelog copies only the changeset (.changeset/README.md), and its Verify: doesn't mention that live items no longer carry value. Consider a paragraph saying li.value read from the editor now reads 0 and li[value] or attr(value) CSS stops matching, pointing to ListItemNode.getValue() or exportDOM. Whether that counts as [breaking] under the README's definition is the maintainers' call.

  • An item hidden with display: none is still counted by Lexical but not by the browser, so items after it now draw one lower than before. Worth a line next to the reversed caveat.

  • With a theme class on list items, exportDOM now emits <li class="..." value="1"> instead of <li value="1" class="...">. The numbers are the same, but "exportDOM unchanged" isn't byte-for-byte true, and snapshot tests of exported HTML may change.
  • Automated review (maintainer link)

    <!-- codebunny-pub:1 k=d891a246361c8f67beb0d0dfa3e3cab74f15e15d6ef983b01bc1de25fbc6d624 -->

    rootnode-bot[bot] rootnode-bot[bot] commented on code on Nov 20, 2026 21:00 UTC
    Code Review
    packages/lexical-list/src/__tests__/browser/ListItemDrawnNumbers.test.ts:1
    @@ -0,0 +1,221 @@
    +/**
    + * Copyright (c) Meta Platforms, Inc. and affiliates.
    + *
    + * This source code is licensed under the MIT license found in the
    + * LICENSE file in the root directory of this source tree.
    + *
    + */
    +
    +// The list's drawn-number cases in a real browser: the number compared with
    +// each item's `getValue()` is the marker the browser itself draws, read from
    +// its accessibility tree (a ListMarker per drawn item), not computed from the
    +// attributes.
    +
    +import {
    +  $createListNode,
    +  $isListItemNode,
    +  ListItemNode,
    +  ListNode,
    +} from '@lexical/list';
    +import {
    +  $getNearestNodeFromDOMNode,
    +  $getRoot,
    +  createEditor,
    +  type LexicalEditor,
    +  ParagraphNode,
    +  TextNode,
    +} from 'lexical';
    +import {expect, onTestFinished, test} from 'vitest';
    +import {cdp} from 'vitest/browser';
    +
    +import {$item, LIST_EDIT_CASES} from '../unit/listEditCases';
    +
    +interface FrameTree {
    +  frame: {id: string};
    +  childFrames?: FrameTree[];
    +}
    +
    +interface AXNode {
    +  nodeId: string;
    +  parentId?: string;
    +  backendDOMNodeId?: number;
    +  role?: {value: string};
    +  name?: {value: string};
    +}
    +
    +/**
    + * The number the browser draws for each item, keyed by the item's position
    + * among the editor's `<li>` elements.
    + */
    +async function drawnMarkers(root: HTMLElement): Promise<Map<number, number>> {
    +  root.querySelectorAll('li').forEach((li, i) => {
    +    li.setAttribute('data-test-index', String(i));
    +  });
    +  // The test runs in a frame of the runner's page: read every frame's tree.
    +  const {frameTree} = (await cdp().send('Page.getFrameTree')) as {

    Optional, but worth doing before merge: cdp() only works in Chromium. With VITEST_BROWSER=firefox all 50 tests in this file fail with browserContext.newCDPSession: CDP session is only available in Chromium, and .github/workflows/tests-extended.yml runs the browser suite on Firefox and WebKit once the PR is approved or labelled extended-tests. Gating the file, for example describe.runIf(server.browser === 'chromium') (as other browser tests branch on server.browser), keeps those jobs green.

    rootnode-bot[bot] rootnode-bot[bot] commented on code on Nov 20, 2026 21:00 UTC
    Code Review
    packages/lexical-list/src/LexicalListItemNode.ts:1
    @@ -962,3 +978,57 @@ export function $isListItemNode(
     ): node is ListItemNode {
       return node instanceof ListItemNode;
     }
    +
    +/**
    + * Writes `li.value` only where the item's number differs from the one the
    + * browser draws from the list's own count: the `<ol start>` for the first
    + * item, otherwise the previous item's number plus one. Every item still shows
    + * its `__value`; bullet and check items never carry a `value`.
    + *
    + * Setting `HTMLLIElement.value` invalidates the whole list's ordinal cache in
    + * Blink, and inserting an item renumbers (and reconciles) every item after it,
    + * so writing it on every item made an insert near the top of an n-item list
    + * O(n^2).
    + */
    +function $updateListItemValueDOM(dom: HTMLLIElement, node: ListItemNode): void {
    +  if (exportingListItemValues) {
    +    dom.value = node.__value;
    +    return;
    +  }
    +  const parent = node.getParent();
    +  if ($isListNode(parent) && parent.getListType() === 'number') {
    +    const prev = node.getPreviousSibling();
    +    const shown = $isListItemNode(prev)
    +      ? prev.getValue() + 1
    +      : parent.getStart();

    Nit, optional: the first item's decision reads parent.getStart(), but ListNode.updateDOM only rewrites <ol start>, and the first item is not dirty when only __start changes. In an update with skipTransforms: true, list.setStart(5) on items 1 and 2 leaves the editor drawing 5 and 6 while the model shows 1 and 2 (main draws 1 and 2). The next transform-running edit converges, so it only affects code that skips transforms; re-deciding the first item when __start changes would mirror the updateDOM fix above.

    rootnode-bot[bot] rootnode-bot[bot] approved these changes on Nov 20, 2026 21:00 UTC
    Approved Reviewer

    The change looks good: numbered items keep the numbers they showed before, exported and copied HTML still carries value on every item, and the re-check in ListItemNode.updateDOM fixes the stale number after a renumbered wrapper (the new drawn-number tests fail against the first commit, in jsdom and on a collaborating peer, and pass on this head). The suggestions below are optional and non-blocking, though the first one is worth doing before merge.

    1. Gate the new browser test on Chromium (packages/lexical-list/src/__tests__/browser/ListItemDrawnNumbers.test.ts:55). drawnMarkers reads the accessibility tree through cdp(), which Playwright only provides in Chromium. Run with VITEST_BROWSER=firefox, all 50 tests fail with browserContext.newCDPSession: CDP session is only available in Chromium. .github/workflows/tests-extended.yml runs the browser suite on Firefox and WebKit once a PR is approved or labelled extended-tests, so those jobs would go red here and on every later PR. AGENTS.md says the browser set comes from VITEST_BROWSER; other browser tests branch on server.browser (for example packages/lexical-playground/src/__tests__/browser/Hashtags.test.ts). Wrapping these cases in describe.runIf(server.browser === 'chromium') would fix it.
    2. Nit: a start change made without the list transform. ListNode.updateDOM updates <ol start> but nothing re-decides the first item, which is not dirty when only __start changes. In an update with skipTransforms: true, list.setStart(5) on items numbered 1 and 2 leaves the editor drawing 5 and 6 while the model (and main) show 1 and 2. The next edit that runs the list transform converges, so this only matters for code that skips transforms. If you want the description's "the number the browser shows always equals __value" to hold there too, mirror the item-level fix when __start changes.
    3. Nit: subclasses that export through createDOM. The export flag is private, so a ListItemNode subclass whose exportDOM calls this.createDOM(editor._config) instead of super.exportDOM(editor) now exports value only where the live count differs, and a partial copy that starts mid-list loses its numbers in other apps. One sentence in the changeset ("call super.exportDOM() to keep value on exported items") would cover it.

    Thanks for the thorough before/after evidence and the mutation checks on the @lexical/y assertions.

    Automated review (maintainer link)

    <!-- codebunny-pub:1 k=ad203a6addaae8b29c74f2f74590ab33f56ec938f82ef1afccf30e7c4bf592da -->

    rootnode-bot[bot] rootnode-bot[bot] commented on code on Nov 23, 2026 03:09 UTC
    Code Review
    packages/lexical-playground/src/__tests__/browser/ListsHTMLCopyAndPaste.test.ts:1
    @@ -252,7 +240,7 @@ test('Copy + paste a checklist', async () => {
       const {root} = setupPasteEditor();
     
       const clipboard = {
    -    'text/html': `<meta charset='utf-8'><ul __lexicallisttype="check"><li role="checkbox" tabindex="-1" aria-checked="false" value="1" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__listItemUnchecked"><span>Hello</span></li><li role="checkbox" tabindex="-1" aria-checked="false" value="2" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__listItemUnchecked"><span>world</span></li></ul>`,
    +    'text/html': `<meta charset='utf-8'><ul __lexicallisttype="check"><li role="checkbox" tabindex="-1" aria-checked="false" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__listItemUnchecked"><span>Hello</span></li><li role="checkbox" tabindex="-1" aria-checked="false" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__listItemUnchecked"><span>world</span></li></ul>`,

    Optional: this line (and :277) drops value from the pasted clipboard HTML, not only from the expected editor HTML. Import ignores value, so the test still passes, but Lexical's own exportDOM still writes value="1"/value="2" here, so keeping the original payload keeps this a faithful round trip (and matches the description's note that pasted inputs keep their values).

    rootnode-bot[bot] rootnode-bot[bot] commented on code on Nov 23, 2026 03:09 UTC
    Code Review
    packages/lexical-list/src/LexicalListItemNode.ts:1
    @@ -962,3 +978,57 @@ export function $isListItemNode(
     ): node is ListItemNode {
       return node instanceof ListItemNode;
     }
    +
    +/**
    + * Writes `li.value` only where the item's number differs from the one the
    + * browser draws from the list's own count: the `<ol start>` for the first
    + * item, otherwise the previous item's number plus one. Every item still shows
    + * its `__value`; bullet and check items never carry a `value`.
    + *
    + * Setting `HTMLLIElement.value` invalidates the whole list's ordinal cache in
    + * Blink, and inserting an item renumbers (and reconciles) every item after it,
    + * so writing it on every item made an insert near the top of an n-item list
    + * O(n^2).

    Optional: worth one sentence here (or in the description) that lists with many nested sublists keep most of the old cost: every item after a wrapper still needs value and is rewritten on each insert above it, since Lexical skips the wrapper in its count and the browser does not.

    rootnode-bot[bot] rootnode-bot[bot] commented on code on Nov 23, 2026 03:09 UTC
    Code Review
    packages/lexical-list/src/LexicalListItemNode.ts:1
    @@ -331,11 +331,27 @@ export class ListItemNode extends ElementNode {
         // @ts-expect-error - this is always HTMLListItemElement
         const element: HTMLLIElement = dom;
         this.updateListItemDOM(prevNode, element, config);
    +    if (prevNode.__value !== this.__value) {
    +      // The next item's `value` is decided from this item's number, and the
    +      // next item is not always reconciled when only this one is renumbered
    +      // (an item that wraps a nested list keeps the number of the item after
    +      // it, so inserting above it renumbers the wrapper but not that item).
    +      $updateNextListItemValueDOM(this);
    +    }
         return false;
       }
     
       exportDOM(editor: LexicalEditor): DOMExportOutput {
    -    const element = this.createDOM(editor._config);
    +    // Exported HTML keeps every item's value, so pasted lists number as before,
    +    // written where `createDOM` always wrote it.

    Optional: the flag is set only here, so a subclass that overrides exportDOM and builds its element with this.createDOM(editor._config) (as this method does) instead of calling super.exportDOM(editor) now exports without value on most items. A line in the changeset would help anyone with such a subclass.

    rootnode-bot[bot] rootnode-bot[bot] approved these changes on Nov 23, 2026 03:09 UTC
    Approved Reviewer

    This looks good to me. The rule in $updateListItemValueDOM is easy to follow, the export path keeps value exactly where it was, and the drawn-number cases (jsdom, a collaborating peer on v1 and v2, and Chromium's accessibility tree) make the guarantee concrete. The wrapper-renumber case from the earlier round is fixed by the updateDOM hook and pinned in all three tiers, and the CDP-based browser tests are now skipped outside Chromium.

    Everything below is optional and non-blocking:

    1. Transform-free setStart (packages/lexical-list/src/LexicalListItemNode.ts:1003, packages/lexical-list/src/LexicalListNode.ts:229-231). The first item is decided from parent.getStart(), but it is not reconciled when only __start changes. In an update with skipTransforms: true, list.setStart(5) on items a and b makes the editor draw 5 and 6 while the model still says 1 and 2 (main draws 1 and 2). Re-deciding the first ListItemNode child from ListNode.updateDOM when __start changes, the way updateDOM already re-decides the next item, would close this. A case for it in listEditCases.ts would keep it closed.
    2. Checklist paste input (packages/lexical-playground/src/__tests__/browser/ListsHTMLCopyAndPaste.test.ts:243 and :277). These lines drop value from the pasted clipboard HTML, not only from the expected editor HTML. Import ignores value, so the test still passes, but Lexical's own exportDOM still writes value, so keeping the original payload keeps the test a faithful round trip. This also matches the description's note that pasted inputs keep their values.
    3. Nested outlines (packages/lexical-list/src/LexicalListItemNode.ts:982-992). Every item after a wrapper still needs value, so a list with a sublist under most items still rewrites one value per wrapper below an insert and keeps most of the old cost. That is inherent while the model skips wrappers, and one sentence in the JSDoc or the description would set expectations.
    4. Subclasses with their own exportDOM. The flag is set only inside ListItemNode.exportDOM, so a subclass that builds its export element with this.createDOM(...) instead of super.exportDOM(editor) now exports without value on most items. A line in the changeset would help anyone with such a subclass.
    5. Changeset category. The entry follows the "Behavior changes" form in .changeset/README.md ([fix] with Verify:), which fits a DOM-output change. The README's table also calls a change [breaking] when "code that worked before has to change", and code reading li.value off the editor does. Either category is defensible, so this is a maintainer's call. If it becomes [breaking], it needs a Detect: line (reads of .value on editor <li>s, li[value], attr(value)).

    Automated review (maintainer link)

    <!-- codebunny-pub:1 k=a1594d1f9217295bb14d8161c268246cf00839d33b94888ec2e847ef38576543 -->

    potatowagon potatowagon approved these changes on Nov 23, 2026 11:17 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    emilyhorsman emilyhorsman
    Labels
    risk: low confidence: 73.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 71.5% (HIGH) · Higher = larger blast radius
    71.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 73.2% · Lower = rushed or shallow review
    73.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.1% · Safe to merge
    19.1%
    Repository