You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[lexical-react] Bug Fix: Update the typeahead query during IME composition - #8942
LexicalTypeaheadMenuPlugin does not update its query while an IME composition is in progress, so the menu keeps showing results for the text that preceded the composition. Typing /한글 shows the results for /, and they only catch up once composition ends.
This is a follow-up to #7987 (fix for #7985). That PR stopped the menu from closing mid-composition by bailing out of the update listener entirely:
if(editor.isComposing()){return;}
The bail-out is wider than the problem it solves. Only the closing is undesirable during composition — the trigger match and onQueryChange are still meaningful, and skipping them is what leaves the menu stale.
What changed
packages/lexical-react
Narrow the composition guard to the close paths
closeUnlessComposing() replaces the early return, so triggerFn and onQueryChange run while composing and the menu filters as you type.
Of the three new IME composition tests, reports the query while composing without closing the menu fails (expected "vi.fn()" to be called with arguments: [ '햄' ] / Number of calls: 0), because the update listener returns early while editor.isComposing() is true and never computes the query.
The other two pass on main as well — they guard against the opposite regression, where the menu would close mid-composition.
meta-claBot
added
the
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
label
Aug 7, 2026
Looks good to me. The original isComposing() guard was too wide — it kept the menu from closing, but also froze the query. Wrapping just the close calls is the right fix.
During IME, lexical's RangeSelection.isCollapsed() stays true (anchor === focus after insertText), so the trigger match and onQueryChange path works fine without the early return. Leaving registerEditableListener calling closeTypeahead() directly also makes sense — going non-editable should close the menu regardless.
Unrelated to this PR but I noticed tryToPositionRange returns boolean while the check on line 247 is isRangePositioned !== null — always true. Before this change the path was unreachable during composition, now it runs. Probably worth a separate if (isRangePositioned) fix.
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
CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.extended-testsRun extended e2e tests on a PR
3 participants
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
LexicalTypeaheadMenuPlugindoes not update its query while an IME composition is in progress, so the menu keeps showing results for the text that preceded the composition. Typing/한글shows the results for/, and they only catch up once composition ends.This is a follow-up to #7987 (fix for #7985). That PR stopped the menu from closing mid-composition by bailing out of the update listener entirely:
The bail-out is wider than the problem it solves. Only the closing is undesirable during composition — the trigger match and onQueryChange are still meaningful, and skipping them is what leaves the menu stale.
What changed
packages/lexical-reactcloseUnlessComposing()replaces the early return, sotriggerFnandonQueryChangerun while composing and the menu filters as you type.Test plan
document.body, so a test ending with it open leaked into later testsBefore
reports the query while composing without closing the menufails (expected "vi.fn()" to be called with arguments: [ '햄' ]/Number of calls: 0), because the update listener returns early whileeditor.isComposing()is true and never computes the query.mainas well — they guard against the opposite regression, where the menu would close mid-composition.After
Related: #7985, #7987