Repository navigation
Description
Lexical version: 0.45 (latest main fd2e1856c)
Found while manual-testing #8594. The Korean IME path looks like it has been broken since the TabNode.setTextContent invariant was added, but it's not in any of the existing reports I could find — probably a long-standing edge case.
Steps To Reproduce
- Open https://playground.lexical.dev in Safari on macOS.
- Type
foo. - Press
Tab. - Start typing Korean (e.g.
ㅁ).
2026-05-30.11.34.14.mov
Reproduces on:
- macOS Safari (verified 26.3.1).
- Deployed
playground.lexical.devand a localvite build+vite previewoflexical-playground(production build). - Local
vite dev(development build). - All Lexical revisions tested via bisect, including a 2025-02 baseline.
Does not reproduce in Chromium with the same Korean IME.
Link to code example: playground.lexical.dev (default configuration).
The current behavior
The editor freezes: composition stays stuck, Backspace and Enter stop responding, English input doesn't recover the editor. Esc partially restores it (English works again), clicking outside and back partially restores Enter; only a hard refresh is a full recovery.
What I observed in DevTools:
After Tab + the first Korean key, Safari's MutationObserver delivers a text change on the TabNode's \t text node — composition targets the <span>\t</span> and Safari writes the new character into the existing text node (\tㅁ).
flushMutations translates that into TabNode.setTextContent('\tㅁ'). The current setTextContent throws (devInvariant against '\t' / ''). The throw goes through onError and breaks the active update; subsequent input / selection / composition events keep re-entering the same broken path:
Error: TabNode does not support setTextContent
flushMutations
Error: $getTextNodeOffset: invalid offset 2 for size 1 at key 5
onCompositionStart
onInput
onSelectionChange
In the dev bundle the readable message shows. In a local vite build of the playground the minified prod bundle still throws — the call site bundles to a function(t){throw new Error(t)} rather than a warn-only formatter. Whatever transformErrorMessages rewrite the Lexical npm release uses for devInvariant doesn't reach this build, so the throw still cascades end-to-end.
Existing context:
- Bug: Typing to a selection including TabNode and TextNode adds text to TabNode #7601 (closed by [lexical][lexical-selection] Bug Fix: Treat all TabNode as if they are in token mode #7602) covered the "select TabNode + adjacent text, type → text inserted into TabNode" path. That selection path is fixed (token-mode TabNode); this IME path is a different hit on the same
setTextContent. - [lexical] Chore: Change TabNode.setTextContent invariant to devInvariant #7855 already noted that the production throw on
TabNode.setTextContenthad cost users sync state ("documents weren't syncing correctly"). The intent of movinginvarianttodevInvariantwas to silence the throw in prod, but as the bundle above shows, in at least our local prod build the call still throws.
The expected behavior
Tab followed by Korean IME composition should behave the same as in Chromium: the Tab character stays in the document as a TabNode, IME composition completes on a new TextNode next to it, and the editor remains responsive.
Making TabNode.setTextContent accept any input and silently normalize to '\t' clears the cascade in both dev and prod for me:
setTextContent(_text: string): this {
return super.setTextContent('\t');
}After the change: Korean composition completes, Backspace removes the TabNode, Enter inserts a paragraph, English typing resumes, copy/paste preserves \t, Markdown shortcuts still fire.
A follow-up PR with a unit test that simulates the MutationObserver-driven setTextContent('\tX') call would keep the regression out. If the throw should stay (e.g. a different flushMutations hook strips the foreign text before reaching setTextContent), point at the better shape and I'll move that direction.
Impact of fix
- Severity: editor unrecoverably frozen after a common keystroke sequence; requires a hard refresh.
- Affects any Lexical-based editor that enables
TabIndentationExtension(or otherwise insertsTabNode) and is used by Korean / Japanese / similar IME users on Safari. CJK-language adoption surface area. - Fix is one line plus a unit test.
Activity
etrepum commentedon May 30, 2026
Are you sure that this doesn't create a different class of bug where the additional text is just lost?
mayrang commentedon May 30, 2026
When filing the issue I tried the normalize-to-
\tapproach locally and exercised the sameTab+ Korean composition path, plus a few neighboring cases (Backspace removing theTabNode, Enter, English typing, copy/paste). Nothing visibly went missing in the editor state. To check that more directly I attached a MutationObserver on the contenteditable and ranfoo + Tab + 안녕하세요:Tree view after the repro:
The Korean character lands on a new sibling text node — the input /
CONTROLLED_TEXT_INSERTIONpath picks it up after the normalize. I haven't traced down to the exact handler that creates the sibling, but the sibling-text-node result is reproducible across a few different first jamos and longer compositions.[lexical] Bug Fix: TabNode.setTextContent silently normalizes to \t f…
test(swift): port LexicalTabNode.test.tsx