Skip to content

[lexical-react][lexical-playground] Bug Fix: restore focus after dragging decorator blocks - #9064

Merged
etrepum merged 2 commits into
meta:mainfrom
luantaraschi:fix-decorator-drag-focus
Aug 13, 2026
Merged

etrepum merged 2 commits into
meta:mainfrom
luantaraschi:fix-decorator-drag-focus

Conversation

@luantaraschi

@luantaraschi luantaraschi commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

Dragging a selected decorator block can leave focus outside the editor. The selected node still appears active, but keyboard input no longer reaches the contenteditable root.

Firefox can blur the editor before dragstart, so the plugin restores focus from its Firefox-specific blur and drag handlers. Chromium and WebKit can instead lose focus when the drag ends. This change uses one restoreEditorFocus helper for both paths and applies the same recovery from dragend.

Closes #9048

Test plan

Before

The new E2E regression failed in Chromium and WebKit because the contenteditable root remained unfocused after dragging a selected YouTube decorator block. The test skipped Firefox.

After

The focused regression passes in Chromium, Firefox, and WebKit:

3 passed (6.8s)

The complete DraggableBlock file passes all five Chromium tests. In the cross-browser run, the new regression also passed in Firefox and WebKit. Two older WebKit drag-placement cases still fail locally without touching the new focus assertion.

Prettier and ESLint pass for both changed files.

…ging decorator blocks

## Description

Restore the editor's DOM focus when a draggable block operation ends without replacing an existing node selection. Marking the selection dirty keeps the DOM selection synchronized while preserving decorator selection.

Closes meta#9048

## Test plan

### Before

The new E2E regression failed in Chromium and WebKit because the contenteditable root remained unfocused after dragging a selected YouTube decorator block.

### After

The regression passes in Chromium and WebKit. The complete DraggableBlock E2E file passes in Chromium (5 tests). Prettier and ESLint pass for the changed files.

Firefox is excluded because the existing draggable-block E2E coverage skips it for platform-specific drag behavior.
@vercel

vercel Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Aug 13, 2026 6:52am
lexical-playground Ready Ready Preview Aug 13, 2026 6:52am

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 Aug 11, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Aug 13, 2026
…estoration

## Description

Consolidate the repeated focus restoration logic into a shared helper and run the decorator drag regression in Firefox as well as Chromium and WebKit.

## Test plan

### Before

The decorator focus regression explicitly skipped Firefox, and focus restoration was repeated in four drag and blur paths.

### After

The focused regression passed in Chromium, Firefox, and WebKit: 3 passed (6.8s).

Prettier and ESLint passed for both changed files, and git diff --check reported no whitespace errors.
@etrepum
etrepum added this pull request to the merge queue Aug 13, 2026
Merged via the queue into meta:main with commit 1fa5018 Aug 13, 2026
52 checks passed
@etrepum etrepum mentioned this pull request Aug 31, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 6323de43 Deployed Aug 13, 2026 by vercel[bot]
Preview – lexical-playground — 6323de43 Deployed Aug 13, 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.

Bug: Keys don't work after moving the selected decorator node

2 participants