Skip to content

[lexical-react] Bug Fix: Ignore stale asynchronous typeahead close completions - #9332

Merged
etrepum merged 4 commits into
meta:mainfrom
Tabisharaza:fix/stale-typeahead-close
Oct 7, 2026
Merged

etrepum merged 4 commits into
meta:mainfrom
Tabisharaza:fix/stale-typeahead-close

Conversation

@Tabisharaza

@Tabisharaza Tabisharaza commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

An asynchronous LexicalTypeaheadMenuPlugin onClose callback currently clears the menu even if another query has opened while the callback was pending. Both a fulfilled and a rejected callback can dismiss the newer query.

Track each open request with a generation counter and let a close completion clear the menu only if no later open was requested. The counter advances when an open is requested, before its React transition commits, so a close issued after a pending open still clears that query. Synchronous close timing and the existing PromiseLike<void> API are unchanged.

Add deterministic regression coverage for fulfilled and rejected closes, repeated close requests, continued editing of the newer query, and synchronous/resolved/rejected closes after a queued open.

AI assistance: This patch and its regression tests were developed and reviewed with OpenAI Codex. The checks below were executed against the resulting code.

Test plan

Before

With the tests applied to upstream 07ded8cbd301d437d8a894e6844bc18f5e74f91c:

pnpm run test-unit packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx --maxWorkers=1
 ❯ |unit| packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx (18 tests | 4 failed) 407ms
   ❯ LexicalTypeaheadMenuPlugin (18)
     ❯ onClose (9)
       × preserves a newer query when an earlier onClose promise resolves after 1 close requests 31ms
       × preserves a newer query when an earlier onClose promise rejects after 1 close requests 25ms
       × preserves a newer query when an earlier onClose promise resolves after 2 close requests 21ms
       × preserves a newer query when an earlier onClose promise rejects after 2 close requests 22ms

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 4 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  |unit| packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx > LexicalTypeaheadMenuPlugin > onClose > preserves a newer query when an earlier onClose promise resolves after 1 close requests
 FAIL  |unit| packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx > LexicalTypeaheadMenuPlugin > onClose > preserves a newer query when an earlier onClose promise rejects after 1 close requests
 FAIL  |unit| packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx > LexicalTypeaheadMenuPlugin > onClose > preserves a newer query when an earlier onClose promise resolves after 2 close requests
 FAIL  |unit| packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx > LexicalTypeaheadMenuPlugin > onClose > preserves a newer query when an earlier onClose promise rejects after 2 close requests
AssertionError: expected undefined to be 'new' // Object.is equality

- Expected:
"new"

+ Received:
undefined

 ❯ packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx:497:11
    495|           document.querySelector('[data-testid="matching-string"]')
    496|             ?.textContent,
    497|         ).toBe('new');
       |           ^
    498|
    499|         await insertText('er');

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/4]⎯


 Test Files  1 failed (1)
      Tests  4 failed | 14 passed (18)
   Start at  14:18:33
   Duration  1.41s (environment 45%, tests 31%, import 11%, worker 9%, transform 3%, setup 1%)

After

pnpm run test-unit packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx --maxWorkers=1
Test Files  1 passed (1)
      Tests  18 passed (18)
   Start at  14:19:03
   Duration  1.53s (environment 47%, tests 31%, import 11%, worker 7%, transform 3%, setup 1%)
pnpm run test-unit --maxWorkers=1 --vmMemoryLimit=512MB
Test Files  380 passed (380)
      Tests  9271 passed | 1 skipped (9272)
   Start at  14:19:06
   Duration  128.53s (tests 45%, import 32%, transform 9%, environment 6%, worker 5%, setup 2%)
NODE_OPTIONS=--max-old-space-size=2048 pnpm run ci-check --max-parallel 1
$ npm-run-all --parallel tsc tsc-test tsc-scripts tsc-extension tsc-website flow prettier lint --max-parallel 1
$ tsc
$ tsc -p ./tsconfig.test.json
$ tsc -p ./tsconfig.scripts.json
$ pnpm --filter @lexical/devtools run compile
$ tsc --noEmit
$ pnpm --filter @lexical/website run tsc
$ tsc -p tsconfig.json
$ node ./scripts/check-flow-types.mjs
Running Flow...
Found 0 errors
$ prettier --list-different .
$ eslint ./

The aggregate check exited successfully. git diff --check also passed.

Tested on Linux with Node v24.19.0 and pnpm v11.19.0. Browser, E2E, integration, builds, and other OS/Node combinations were not run.

…mpletions

## Description

An asynchronous `LexicalTypeaheadMenuPlugin` `onClose` callback currently clears the menu even if another query has opened while the callback was pending. Both a fulfilled and a rejected callback can dismiss the newer query.

Track each open request with a generation counter and let a close completion clear the menu only if no later open was requested. The counter advances when an open is requested, before its React transition commits, so a close issued after a pending open still clears that query. Synchronous close timing and the existing `PromiseLike<void>` API are unchanged.

Add deterministic regression coverage for fulfilled and rejected closes, repeated close requests, continued editing of the newer query, and synchronous/resolved/rejected closes after a queued open.

AI assistance: This patch and its regression tests were developed and reviewed with OpenAI Codex. The checks below were executed against the resulting code.

## Test plan

### Before

With the tests applied to upstream `07ded8cbd301d437d8a894e6844bc18f5e74f91c`:

```sh
pnpm run test-unit packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx --maxWorkers=1
```

```text
 ❯ |unit| packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx (18 tests | 4 failed) 407ms
   ❯ LexicalTypeaheadMenuPlugin (18)
     ❯ onClose (9)
       × preserves a newer query when an earlier onClose promise resolves after 1 close requests 31ms
       × preserves a newer query when an earlier onClose promise rejects after 1 close requests 25ms
       × preserves a newer query when an earlier onClose promise resolves after 2 close requests 21ms
       × preserves a newer query when an earlier onClose promise rejects after 2 close requests 22ms

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 4 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  |unit| packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx > LexicalTypeaheadMenuPlugin > onClose > preserves a newer query when an earlier onClose promise resolves after 1 close requests
 FAIL  |unit| packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx > LexicalTypeaheadMenuPlugin > onClose > preserves a newer query when an earlier onClose promise rejects after 1 close requests
 FAIL  |unit| packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx > LexicalTypeaheadMenuPlugin > onClose > preserves a newer query when an earlier onClose promise resolves after 2 close requests
 FAIL  |unit| packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx > LexicalTypeaheadMenuPlugin > onClose > preserves a newer query when an earlier onClose promise rejects after 2 close requests
AssertionError: expected undefined to be 'new' // Object.is equality

- Expected:
"new"

+ Received:
undefined

 ❯ packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx:497:11
    495|           document.querySelector('[data-testid="matching-string"]')
    496|             ?.textContent,
    497|         ).toBe('new');
       |           ^
    498|
    499|         await insertText('er');

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/4]⎯


 Test Files  1 failed (1)
      Tests  4 failed | 14 passed (18)
   Start at  14:18:33
   Duration  1.41s (environment 45%, tests 31%, import 11%, worker 9%, transform 3%, setup 1%)
```

### After

```sh
pnpm run test-unit packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx --maxWorkers=1
```

```text
Test Files  1 passed (1)
      Tests  18 passed (18)
   Start at  14:19:03
   Duration  1.53s (environment 47%, tests 31%, import 11%, worker 7%, transform 3%, setup 1%)
```

```sh
pnpm run test-unit --maxWorkers=1 --vmMemoryLimit=512MB
```

```text
Test Files  380 passed (380)
      Tests  9271 passed | 1 skipped (9272)
   Start at  14:19:06
   Duration  128.53s (tests 45%, import 32%, transform 9%, environment 6%, worker 5%, setup 2%)
```

```sh
NODE_OPTIONS=--max-old-space-size=2048 pnpm run ci-check --max-parallel 1
```

```text
$ npm-run-all --parallel tsc tsc-test tsc-scripts tsc-extension tsc-website flow prettier lint --max-parallel 1
$ tsc
$ tsc -p ./tsconfig.test.json
$ tsc -p ./tsconfig.scripts.json
$ pnpm --filter @lexical/devtools run compile
$ tsc --noEmit
$ pnpm --filter @lexical/website run tsc
$ tsc -p tsconfig.json
$ node ./scripts/check-flow-types.mjs
Running Flow...
Found 0 errors
$ prettier --list-different .
$ eslint ./
```

The aggregate check exited successfully. `git diff --check` also passed.

Tested on Linux with Node v24.19.0 and pnpm v11.19.0. Browser, E2E, integration, builds, and other OS/Node combinations were not run.
@vercel

vercel Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Oct 6, 2026 4:49pm UTC
lexical-playground Ready Ready Preview Oct 6, 2026 4:49pm UTC

Request Review

@meta-cla meta-cla Bot 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 Oct 6, 2026
@etrepum etrepum changed the title [lexical-react] Bug Fix: Ignore stale asynchronous typeahead close co… [lexical-react] Bug Fix: Ignore stale asynchronous typeahead close completions Oct 6, 2026
claude and others added 2 commits October 6, 2026 16:43
## Description

Builds on the stale async close fix in this branch. LexicalTypeaheadMenuPlugin decided whether to call onOpen or onClose from the rendered `resolution`, which lags both a pending open and a pending close:

- When a newer query opened while an async onClose was pending, the newer query never got onOpen, though the consumer had already been told the menu closed (open, close, close instead of open, close, open, close).
- A second close request during a pending close called onClose again.
- A non-matching update that arrived before the first open had rendered skipped the close, so the menu showed for text that no longer matched (also on main).
- When LexicalMenu hid the menu because its trigger scrolled out of view, it cleared the resolution directly and onClose never ran.
- `isRangePositioned !== null` was always true, so the menu opened at a zero rect when the query could not be positioned (no DOM selection, a non-collapsed one, or an offset out of range).

A ref now records whether the menu is open as far as onOpen and onClose know, set in openTypeahead and cleared in closeTypeahead, and both callbacks key off it instead of `resolution`. The generation check that ignores a stale close stays. The out-of-view hide goes through closeTypeahead, and an unpositioned query closes instead of opening.

## Test plan

### Before

`./node_modules/.bin/vitest run --project unit packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx` with the new tests and the plugin from the parent commit:

```
       × preserves a newer query when an earlier onClose promise resolves after 1 close requests 41ms
       × preserves a newer query when an earlier onClose promise rejects after 1 close requests 29ms
       × preserves a newer query when an earlier onClose promise resolves after 2 close requests 16ms
       × preserves a newer query when an earlier onClose promise rejects after 2 close requests 17ms
       × closes a first query that has not rendered yet 15ms
       × calls onClose when the menu hides because its trigger scrolled out of view 24ms
       × does not open the menu when the query cannot be positioned 26ms
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 7 ⎯⎯⎯⎯⎯⎯⎯
AssertionError: expected "vi.fn()" to be called 2 times, but got 1 times
AssertionError: expected "vi.fn()" to be called 1 times, but got 2 times
AssertionError: expected "vi.fn()" to be called 1 times, but got 0 times
AssertionError: expected "vi.fn()" to be called 1 times, but got 0 times
AssertionError: expected "vi.fn()" to not be called at all, but actually been called 1 times
      Tests  7 failed | 14 passed (21)
```

### After

```
 Test Files  1 passed (1)
      Tests  21 passed (21)
```

All lexical-react unit tests pass (41 files, 243 tests), and the Chromium e2e specs that use the typeahead (Mentions, ComponentPicker, Autocomplete, Hashtags) pass (17 tests). Firefox and WebKit were not run.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
## Description

The typeahead plugin tests narrowed types with `if (!cond) { throw new Error(...) }`. They now use vitest's `assert`, which narrows the same way and matches the rest of the test suite. No behavior change.

## Test plan

### Before

The six hand-written throws in LexicalTypeaheadMenuPlugin.test.tsx.

### After

`./node_modules/.bin/vitest run --project unit packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx`

```
 Test Files  1 passed (1)
      Tests  21 passed (21)
```

`tsc -p tsconfig.test.json` and eslint pass on the file.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@etrepum
etrepum added this pull request to the merge queue Oct 7, 2026
Merged via the queue into meta:main with commit b36ab04 Oct 7, 2026
48 checks passed
zurfyx added a commit that referenced this pull request Oct 15, 2026
## Description

The changes merged since v0.52.0 predate changesets, so without entries the
v0.53.0 section would leave them out, including the breaking removal of the
deprecated import extensions (#9316).

This adds a changeset for every user-facing pull request in
v0.52.0..main, written from each pull request, with a `PR: #N` line (they
land in this pull request rather than the original ones) and the original
author's handle:

- breaking: #9316, with the full replacement table as `Migration:`
- feature: #9312
- fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319,
  #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302,
  #9261, #9262, #9263, #9258
- perf: #9264

Skipped as not user-facing: dependency bumps (all devDependencies), website
and docs updates, test and CI changes, the private devtools extension and
eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to
`any` change).

It also adds a `[chore]` changeset for this pull request itself, which adds
CHANGELOG.md to the `lexical` package's `files`.

## Test plan

### Before

```
$ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn   # at the previous commit
warning: This pull request changes published code without a changeset for:
  lexical: packages/lexical/package.json (files)
...
Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only.
```

### After

```
$ node scripts/changesets/check.mjs --base origin/main
Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset.
```

The `latest` release step in a throwaway clone of this branch, with the
real tags:

```
$ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30
Added v0.53.0 to CHANGELOG.md from 27 changeset(s).
$ ls .changeset
changelog.cjs
config.json
README.md
$ sed -n 1,9p CHANGELOG.md
## v0.53.0 (2026-10-30)

### Breaking changes

- **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316))

  The deprecated import and alias extensions are removed. The `*ImportRules`
  arrays, including `HorizontalRuleImportRules`, stay.

$ grep -n '^### ' CHANGELOG.md | head -7
3:### Breaking changes
28:### Features
36:### Fixes
98:### Performance
102:### Other
106:### Contributors
110:### All changes
$ sed -n '/^### Contributors/,+2p' CHANGELOG.md
### Contributors

@Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira
$ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2
- [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou
- [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry
```

(`### All changes` has 50 lines: the 48 commits after v0.52.0, without the
`v0.52.0 (#9252)` bump commit, plus this branch's two commits.)

Running again before that release PR is merged:

```
$ git tag v0.53.0   # tagged, but CHANGELOG.md on main has no v0.53.0 section
$ npm_package_version=0.54.0 node scripts/changesets/release.mjs
CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases.
(exit 1)
$ npm_package_version=0.53.1 node scripts/changesets/release.mjs
Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release:
  - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier
Run the release with the "minor" increment instead.
(exit 1)
```

A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built,
so the export check that follows fails as expected):

```
$ node scripts/npm/prepare-release.mjs
[lexical] CHANGELOG.md lists pending changes as Unreleased
[lexical] package.json references files that are not present in packages/lexical:
  ./dist/Lexical.dev.js
$ sed -n 1,5p packages/lexical/CHANGELOG.md
## Unreleased

Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut.

### Breaking changes
$ git status --short CHANGELOG.md
(clean: only the gitignored package copy changed)
```
zurfyx added a commit that referenced this pull request Oct 15, 2026
## Description

The changes merged since v0.52.0 predate changesets, so without entries the
v0.53.0 section would leave them out, including the breaking removal of the
deprecated import extensions (#9316).

This adds a changeset for every user-facing pull request in
v0.52.0..main, written from each pull request, with a `PR: #N` line (they
land in this pull request rather than the original ones) and the original
author's handle:

- breaking: #9316, with the full replacement table as `Migration:`
- feature: #9312
- fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319,
  #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302,
  #9261, #9262, #9263, #9258
- perf: #9264

Skipped as not user-facing: dependency bumps (all devDependencies), website
and docs updates, test and CI changes, the private devtools extension and
eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to
`any` change).

Four fixes change observable output or behavior, so their changesets have
a `Verify:` paragraph and are listed under Behavior changes: #9303 (new
tabs get no `window.opener`), #9272 (imported code content is normalized),
#9261 (`$patchStyleText` styles the selection it is given), #9319 (editor
keys and namespaces are a counter without a DOM).

It also adds a `[chore]` changeset for this pull request itself, which adds
CHANGELOG.md to the `lexical` package's `files`.

## Test plan

### Before

```
$ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn   # at the previous commit
warning: This pull request changes published code without a changeset for:
  lexical: packages/lexical/package.json (files)
...
Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only.
```

### After

```
$ node scripts/changesets/check.mjs --base origin/main
Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset.
```

The `latest` release step in a throwaway clone of this branch, with the
real tags:

```
$ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30
Added v0.53.0 to CHANGELOG.md from 27 changeset(s).
$ ls .changeset
changelog.cjs
config.json
README.md
$ sed -n 1,9p CHANGELOG.md
## v0.53.0 (2026-10-30)

### Breaking changes

- **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316))

  The deprecated import and alias extensions are removed. The `*ImportRules`
  arrays, including `HorizontalRuleImportRules`, stay.

$ grep -n '^### ' CHANGELOG.md | head -8
3:### Breaking changes
28:### Behavior changes
54:### Features
62:### Fixes
108:### Performance
112:### Other
116:### Contributors
120:### All changes
$ sed -n '/^### Behavior changes/,+7p' CHANGELOG.md
### Behavior changes

- **@lexical/link**: Open new-tab links from `ClickableLinkPlugin` / `registerClickableLink` without `window.opener` ([#9303](#9303))

  This prevents the opened page from navigating the editor's tab (reverse tabnabbing). Same-tab opens are unchanged.

  Verify: pages opened from editor links that relied on `window.opener`.

$ node scripts/changesets/range.mjs --from 0.52.0 --breaking --json   # (kind, [(pr, behavior)])
[('breaking', [(9316, False)]), ('behavior', [(9303, True), (9272, True), (9261, True), (9319, True)])]
$ sed -n '/^### Contributors/,+2p' CHANGELOG.md
### Contributors

@Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira
$ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2
- [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou
- [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry
```

(`### All changes` has 50 lines: the 48 commits after v0.52.0, without the
`v0.52.0 (#9252)` bump commit, plus this branch's two commits.)

Running again before that release PR is merged:

```
$ git tag v0.53.0   # tagged, but CHANGELOG.md on main has no v0.53.0 section
$ npm_package_version=0.54.0 node scripts/changesets/release.mjs
CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases.
(exit 1)
$ npm_package_version=0.53.1 node scripts/changesets/release.mjs
Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release:
  - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier
Run the release with the "minor" increment instead.
(exit 1)
```

A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built,
so the export check that follows fails as expected):

```
$ node scripts/npm/prepare-release.mjs
[lexical] CHANGELOG.md lists pending changes as Unreleased
[lexical] package.json references files that are not present in packages/lexical:
  ./dist/Lexical.dev.js
$ sed -n 1,5p packages/lexical/CHANGELOG.md
## Unreleased

Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut.

### Breaking changes
$ git status --short CHANGELOG.md
(clean: only the gitignored package copy changed)
```
zurfyx added a commit that referenced this pull request Oct 15, 2026
## Description

The changes merged since v0.52.0 predate changesets, so without entries the
v0.53.0 section would leave them out, including the breaking removal of the
deprecated import extensions (#9316).

This adds a changeset for every user-facing pull request in
v0.52.0..main, written from each pull request, with a `PR: #N` line (they
land in this pull request rather than the original ones) and the original
author's handle:

- breaking: #9316, with the full replacement table as `Migration:`
- feature: #9312
- fix: #9335, #9332, #9331, #9328, #9325, #9317, #9321, #9320, #9319,
  #9283, #9303, #9295, #9291, #9260, #9300, #9301, #9272, #9267, #9302,
  #9261, #9262, #9263, #9258
- perf: #9264

Skipped as not user-facing: dependency bumps (all devDependencies), website
and docs updates, test and CI changes, the private devtools extension and
eslint-plugin-internal, and #9353 (a behavior-preserving Flow `Object` to
`any` change).

Four fixes change observable output or behavior, so their changesets have
a `Verify:` paragraph and are listed under Behavior changes: #9303 (new
tabs get no `window.opener`), #9272 (imported code content is normalized),
#9261 (`$patchStyleText` styles the selection it is given), #9319 (editor
keys and namespaces are a counter without a DOM).

It also adds a `[chore]` changeset for this pull request itself, which adds
CHANGELOG.md to the `lexical` package's `files`.

## Test plan

### Before

```
$ node scripts/changesets/check.mjs --base origin/main --head HEAD --coverage warn   # at the previous commit
warning: This pull request changes published code without a changeset for:
  lexical: packages/lexical/package.json (files)
...
Changeset check passed: 0 pending changeset(s) valid; coverage: 1 warning(s), reported only.
```

### After

```
$ node scripts/changesets/check.mjs --base origin/main
Changeset check passed: 27 pending changeset(s) valid; coverage: lexical changed, each named by a changeset.
```

The `latest` release step in a throwaway clone of this branch, with the
real tags:

```
$ LATEST_RELEASE=v0.52.0 npm_package_version=0.53.0 node scripts/changesets/release.mjs --date 2026-10-30
Added v0.53.0 to CHANGELOG.md from 27 changeset(s).
$ ls .changeset
changelog.cjs
config.json
README.md
$ sed -n 1,9p CHANGELOG.md
## v0.53.0 (2026-10-30)

### Breaking changes

- **@lexical/code-core, @lexical/code-shiki, @lexical/html, @lexical/link, @lexical/list, @lexical/mdast, @lexical/rich-text, @lexical/table**: Remove the extensions deprecated in v0.52.0 and earlier ([#9316](#9316))

  The deprecated import and alias extensions are removed. The `*ImportRules`
  arrays, including `HorizontalRuleImportRules`, stay.

$ grep -n '^### ' CHANGELOG.md | head -8
3:### Breaking changes
28:### Behavior changes
54:### Features
62:### Fixes
108:### Performance
112:### Other
116:### Contributors
120:### All changes
$ sed -n '/^### Behavior changes/,+7p' CHANGELOG.md
### Behavior changes

- **@lexical/link**: Open new-tab links from `ClickableLinkPlugin` / `registerClickableLink` without `window.opener` ([#9303](#9303))

  This prevents the opened page from navigating the editor's tab (reverse tabnabbing). Same-tab opens are unchanged.

  Verify: pages opened from editor links that relied on `window.opener`.

$ node scripts/changesets/range.mjs --from 0.52.0 --breaking --json   # (kind, [(pr, behavior)])
[('breaking', [(9316, False)]), ('behavior', [(9303, True), (9272, True), (9261, True), (9319, True)])]
$ sed -n '/^### Contributors/,+2p' CHANGELOG.md
### Contributors

@Tabisharaza, @etrepum, @mbret, @maximilliangrand, @Vedthakar, @rinarakaki, @potatowagon, @followdarko, Gerard Rovira
$ sed -n '/^### All changes/,/^## v0.52.0/p' CHANGELOG.md | sed -n '5,6p;$p' | head -2
- [lexical-yjs][Chore] Change last `Object` to `any` in lexical ([#9353](#9353)) Sam Zhou
- [lexical-eslint-plugin-internal] Chore: lint window messaging channel scoping ([#9339](#9339)) Sherry
```

(`### All changes` has 50 lines: the 48 commits after v0.52.0, without the
`v0.52.0 (#9252)` bump commit, plus this branch's two commits.)

Running again before that release PR is merged:

```
$ git tag v0.53.0   # tagged, but CHANGELOG.md on main has no v0.53.0 section
$ npm_package_version=0.54.0 node scripts/changesets/release.mjs
CHANGELOG.md has no v0.53.0 section, so the v0.53.0 release pull request is not merged yet. Merge it (it consumes the changesets for v0.53.0) before cutting v0.54.0; running again now would put the same changesets in both releases.
(exit 1)
$ npm_package_version=0.53.1 node scripts/changesets/release.mjs
Refusing to release 0.53.1 as a patch: 1 pending [breaking] changeset(s) need a minor release:
  - .changeset/remove-deprecated-import-extensions.md: Remove the extensions deprecated in v0.52.0 and earlier
Run the release with the "minor" increment instead.
(exit 1)
```

A prerelease publish (lexical at 0.52.1-nightly.20261016.0, nothing built,
so the export check that follows fails as expected):

```
$ node scripts/npm/prepare-release.mjs
[lexical] CHANGELOG.md lists pending changes as Unreleased
[lexical] package.json references files that are not present in packages/lexical:
  ./dist/Lexical.dev.js
$ sed -n 1,5p packages/lexical/CHANGELOG.md
## Unreleased

Merged after the latest stable release and included in 0.52.1-nightly.20261016.0. These entries move into a version section when the next stable release is cut.

### Breaking changes
$ git status --short CHANGELOG.md
(clean: only the gitignored package copy changed)
```
@zurfyx zurfyx mentioned this pull request Oct 27, 2026
Louayzouaoui1 pushed a commit to Louayzouaoui1/lexical that referenced this pull request Oct 28, 2026
GiorgioPorgio added a commit to GiorgioPorgio/lexical that referenced this pull request Nov 19, 2026
…option is picked before the menu re-renders

## Description

`LexicalTypeaheadMenuPlugin` stores the trigger match in `resolution` inside `startTransition`. An option picked before that transition renders is split off with the previous query's length.

- Typed more, then picked: the start of the query stays in front of the node. On the playground `@Lu`, `ke`, Enter gives `@L` + mention.
- Backspace, then picked: the text before the query is cut. `hello @Luke`, 3 Backspaces, Enter gives `hel` + mention.

It happens when keys queue up behind a busy main thread. On playground.lexical.dev, keys 40 ms apart behind a 150 ms long task reproduce it every time.

Same cause as meta#9332. `openTypeahead` now keeps the resolution it was last given in a ref. The pick splits with it. The ref replaces `openGenerationRef`, since a new object per open tells opens apart like the counter did. The tests from meta#9332 pass unchanged.

Out of scope: Enter while a close is still pending picks with the last open match, as before.

## Changeset

`[fix]` for `@lexical/react`, with a `Verify:` paragraph.

## Test plan

### Before

```
$ pnpm exec vitest run --project unit packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx -t "picking an option"
       × replaces the whole query after more was typed
+   "text": "hello /a[Alpha]",
       × keeps the text before the query after characters were deleted
+   "text": "hel[Alpha]",
```

Playground (`pnpm run dev`, Playwright, headless Chromium): wrong in 60 of 60 runs, both cases, with keys 40 ms apart behind a 150 ms long task and back to back at 1x and 4x CPU.

### After

```
$ pnpm exec vitest run --project unit packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx
      Tests  23 passed (23)
$ pnpm run ci-check
Found 0 errors
$ pnpm run test-unit
      Tests  40241 passed | 423 expected fail | 174 skipped (40838)
```

Playground, same runs: correct in 60 of 60. Only Chromium was tested. Firefox and WebKit were not.
sehnzucht added a commit to sehnzucht/lexical that referenced this pull request Nov 26, 2026
…a transition

## Description

`LexicalTypeaheadMenuPlugin` sets the menu `resolution` inside `startTransition`, on open and on each query change. In a large document where the host keeps rendering after each edit, that transition can wait behind higher-priority work for seconds (median ~12s reported in meta#9976, vs ~1.3s as a normal update).

Add an `openInTransition` prop (default `true`). With `openInTransition={false}`, the resolution is set as a normal React update, so the menu appears with the trigger key without forking the plugin. The default keeps today's behavior.

Same underlying lag as meta#9332 / meta#9953.

Closes meta#9976

## Changeset

```md
---
'@lexical/react': patch
---

[feature] `LexicalTypeaheadMenuPlugin` accepts `openInTransition` (default `true`). Set it to `false` to set the menu resolution, on open and on each query change, as a normal React update instead of inside `startTransition`, so a busy host no longer delays the menu for seconds after the trigger key
```

## Test plan

### Before

New test file run against the plugin from `main`:

```
$ pnpm exec vitest run --project unit packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.openInTransition.test.tsx
 ❯ |unit| packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.openInTransition.test.tsx (2 tests | 1 failed) 94ms
   ❯ LexicalTypeaheadMenuPlugin openInTransition (2)
     × opens without startTransition when openInTransition is false 9ms
AssertionError: expected "vi.fn()" to not be called at all, but actually been called 1 times
 ❯ packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.openInTransition.test.tsx:158:33
    158|     expect(startTransition).not.toHaveBeenCalled();
 Test Files  1 failed (1)
      Tests  1 failed | 1 passed (2)
```

### After

```
$ pnpm exec vitest run --project unit packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.openInTransition.test.tsx packages/lexical-react/src/__tests__/unit/LexicalTypeaheadMenuPlugin.test.tsx
 Test Files  2 passed (2)
      Tests  23 passed (23)
```

This branch was successfully deployed

2 active deployments
Preview – lexical — 685ddf06 Deployed Oct 6, 2026 by vercel[bot]
Preview – lexical-playground — 685ddf06 Deployed Oct 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants