Conversation
…n is force-committed Clicking outside the editor mid-composition makes the browser force-commit and fire compositionend. Because the commit happens before focus actually moves, the editor is still the active element, so every activeElement guard in $updateDOMSelection passes and reconciliation scrolls the caret back into view — undoing the scrolling the user just did to reach whatever they clicked. A plain contenteditable keeps its scroll position under the same gesture. Distinguish keyboard-driven commits from browser-forced ones: a commit typed by the user (Space/Enter, next-syllable, arrows) is always preceded by a keydown on the editor, and one caused by clicking away is not. When the keydown is missing, tag the update with SKIP_SELECTION_FOCUS_TAG and SKIP_SCROLL_INTO_VIEW_TAG, reusing the lastKeyDownTimeStamp heuristic $handleCompositionStart already uses. The committed text is still synced and the selection still reconciled; only the focus grab and the scroll-into-view are suppressed. Android Chrome zeroes lastKeyDownTimeStamp while composing, so the zero check leaves it unchanged. Both routes into compositionend are covered: the immediate one and Firefox's, which defers the commit to the input event that follows. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
reviewed
Jul 14, 2026
etrepum
left a comment
Collaborator
There was a problem hiding this comment.
maybe the shape of $onCompositionEndImpl should change a bit (e.g. to take more parameters and handle exit a bit differently)? it looks like all of the new tagging always goes after that function so perhaps it would be easier if that function was responsible for setting the tags
…ionEndImpl Follow-up to the force-committed-composition scroll fix, addressing review feedback that the tag-setting should belong to $onCompositionEndImpl rather than trail after each of its callers. Moving the tagging inside the function — right after $setCompositionKey(null), before any exit — makes the tag follow from ending the composition instead of from each caller remembering to add it. That closes two gaps the caller-side tagging had left open, both intended: - The token-redirect path in $handleInput only tagged when it actually redirected onto a token node. An ordinary multi-character commit (the common CJK case) ended untagged. It is now tagged. - Safari's deferred 'ending-safari' commit, processed on the following keydown, was never tagged at all. It is now tagged. Because that path finishes the commit later, the compositionend timeStamp is stashed in the new InputState.compositionEndTimeStamp so the classification reads when the composition actually ended, not when we got around to it. Also separates RECENT_KEYDOWN_WINDOW from ANDROID_COMPOSITION_LATENCY. They held the same value but answer different questions — one is how late Android's keyboard delivers events, the other is whether a keystroke is behind a composition event at all — so tuning one must not silently move the other. No value change; the $handleCompositionStart site that was already asking the keydown-recency question is switched to the new name. The scroll-suppression comment now records that SKIP_SCROLL_INTO_VIEW_TAG only suppresses Lexical's own reconciliation scroll (the Chromium case), and does nothing where the browser natively scrolls the caret on commit (observed on Firefox, where a plain contentEditable jumps identically). Adds a Firefox unit test for the multi-character-commit path that the token-redirect gap left untagged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
## Description Merge upstream/main at 0e9a9f5 into the IME forced-commit branch. The PR's keydown-recency constant conflicts with main's lazy initialization of root event handlers. Keep both the constant and the lazy event list so the existing composition-end behavior and main's tree-shaking fix are preserved. ## Test plan ### Before `git merge --no-commit upstream/main` ```text Auto-merging packages/lexical/src/LexicalEditor.ts Auto-merging packages/lexical/src/LexicalEvents.ts CONFLICT (content): Merge conflict in packages/lexical/src/LexicalEvents.ts Automatic merge failed; fix conflicts and then commit the result. ``` ### After Checks ran with Node v24.21.0 and pnpm v11.24.0 after a frozen-lockfile install. `pnpm_config_verify_deps_before_run=false` used the installed dependencies without repeating pnpm's automatic install check in the sandbox. ```sh pnpm_config_verify_deps_before_run=false pnpm run test-unit \ packages/lexical/src/__tests__/unit/LexicalAndroidChromeComposition.test.ts \ packages/lexical/src/__tests__/unit/LexicalFirefoxCompositionEndTag.test.ts \ packages/lexical/src/__tests__/unit/LexicalEventsKeyDown.test.ts \ packages/lexical/src/__tests__/unit/LexicalEventsKeyDownApple.test.ts \ packages/lexical/src/__tests__/unit/LexicalIosKoreanIME.test.ts \ packages/lexical/src/__tests__/unit/IosKeyboardSuggestions.test.ts \ scripts/__tests__/unit/treeShakingSource.test.ts ``` ```text Test Files 7 passed (7) Tests 150 passed (150) ``` ```sh pnpm_config_verify_deps_before_run=false VITEST_BROWSER=chromium,firefox,webkit \ pnpm run test-browser \ packages/lexical/src/__tests__/browser/LexicalCompositionForcedCommit.test.ts \ packages/lexical/src/__tests__/browser/LexicalComposition.test.ts ``` ```text Test Files 6 passed (6) Tests 70 passed | 2 skipped (72) ``` `node_modules/.bin/tsc` and `git diff --cached --check upstream/main` exited 0. ESLint exited 0 for all six PR files. Prettier checked the same files: ```sh pnpm_config_verify_deps_before_run=false pnpm exec eslint \ packages/lexical/src/LexicalEditor.ts \ packages/lexical/src/LexicalEvents.ts \ packages/lexical/src/__tests__/browser/LexicalCompositionForcedCommit.test.ts \ packages/lexical/src/__tests__/browser/utils/compose.ts \ packages/lexical/src/__tests__/unit/LexicalAndroidChromeComposition.test.ts \ packages/lexical/src/__tests__/unit/LexicalFirefoxCompositionEndTag.test.ts pnpm_config_verify_deps_before_run=false pnpm exec prettier --check \ packages/lexical/src/LexicalEditor.ts \ packages/lexical/src/LexicalEvents.ts \ packages/lexical/src/__tests__/browser/LexicalCompositionForcedCommit.test.ts \ packages/lexical/src/__tests__/browser/utils/compose.ts \ packages/lexical/src/__tests__/unit/LexicalAndroidChromeComposition.test.ts \ packages/lexical/src/__tests__/unit/LexicalFirefoxCompositionEndTag.test.ts ``` ```text Checking formatting... All matched files use Prettier code style! ``` Chromium, Firefox, and WebKit ran on macOS. Real OS IME input and Android devices were not exercised. The existing WebKit forced-commit tests still have their documented limitation: deferred composition-end processing is not reached without a subsequent keydown.
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
Describe the changes in this pull request
Closes #8834
Test plan
Before
Insert relevant screenshots/recordings/automated-tests
After
Insert relevant screenshots/recordings/automated-tests