Repository navigation
[lexical][lexical-selection] Bug Fix: Treat all TabNode as if they are in token mode - #7602
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
etrepum
marked this pull request as ready for review
June 3, 2025 18:35
etrepum
requested review from
Fetz,
Sahejkm,
acywatson,
fantactuka,
ivailop7,
lilshady,
potatowagon,
takuyakanbr and
zurfyx
as code owners
June 3, 2025 18:35
ivailop7
approved these changes
Jun 3, 2025
Merged
This was referenced May 30, 2026
mayrang
added a commit
to mayrang/lexical
that referenced
this pull request
May 30, 2026
…or Safari IME compat (facebook#8596) In Safari, the MutationObserver delivers mid-IME-composition text writes straight onto the `TabNode`'s `\t` text node — Korean / Japanese / similar IMEs compose onto the existing text node, and Safari rewrites it to `\tㅁ`. `flushMutations` then calls `TabNode.setTextContent('\tㅁ')`, the `devInvariant` throws, and the throw cascades through `onError`, freezing the editor (composition, Backspace, Enter, English input all stop working until a hard refresh). The throw existed since `TabNode` was introduced, but the only path that surfaced it before was selection-based typing across the node (fixed by treating the node as token-mode in facebook#7602). The MutationObserver / IME path was uncovered. Drop the `devInvariant` check entirely. The body already normalizes to `\t` via `super.setTextContent('\t')`, so the throw never carried information the reconciler couldn't recover from — the next update re-renders the canonical `\t`. A unit test exercises the exact `setTextContent('\tㅁ')` shape `flushMutations` produces so the regression doesn't return.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
For legacy reasons TabNode is a 'normal' mode TextNode with the
IS_UNMERGEABLEdetail flag (used only in the reconciler's normalization), but the conditions in the rest of the core usednode.isToken()to determine if the node should be modified or replaced without checking theIS_UNMERGEABLEflag.To keep legacy serialization as-is, this PR changes the core to use
$isTokenOrTab(new) and$isTokenOrSegmentedfunctions instead of calling theTextNode.isTokenmethod directly, and these functions both now check$isTabNodeas part of their condition.This also changes all property setters of
__textto go through thesetTextContentmethod (except for@lexical/selection's$sliceSelectedTextNodeContentwhich is used in an unusual "read-only" way), and adds an additional invariant toTabNode.spliceTextto ensure that it is not modified by that either.Closes #7601
Test plan
Unit tests to confirm that
TabNodeis not modified in the scenarios from #7601