Skip to content

[lexical-code-core] Bug Fix: detect nested br elements in pasted code#8487

Merged
etrepum merged 1 commit into
facebook:mainfrom
danyalahmed1995:fix/nested-code-br-import
May 10, 2026
Merged

[lexical-code-core] Bug Fix: detect nested br elements in pasted code#8487
etrepum merged 1 commit into
facebook:mainfrom
danyalahmed1995:fix/nested-code-br-import

Conversation

@danyalahmed1995

Copy link
Copy Markdown
Contributor

Summary

Fixes multiline code detection during HTML import when a <br> is nested inside inline markup within a <code> element.

CodeNode.importDOM() already treats multiline <code> content as a code block, but the recursive hasChildDOMNodeTag() helper did not return recursive matches. As a result, markup such as <code><span>1<br>2</span></code> could be imported as inline code instead of a code block.

This updates the helper to return nested matches and adds regression coverage for the nested <br> case.

Test Plan

  • Ran pnpm.cmd exec vitest --project unit packages/lexical/src/__tests__/unit/CodeBlock.test.ts --run

@vercel

vercel Bot commented May 10, 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, Comment May 10, 2026 0:02am
lexical-playground Ready Ready Preview, Comment May 10, 2026 0:02am

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 May 10, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label May 10, 2026
@etrepum etrepum changed the title fix(code): detect nested br elements in pasted code [lexical-code-core] Bug Fix: detect nested br elements in pasted code May 10, 2026
@etrepum etrepum added this pull request to the merge queue May 10, 2026
Merged via the queue into facebook:main with commit bc94d3d May 10, 2026
45 checks passed
@etrepum etrepum mentioned this pull request May 28, 2026
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.

2 participants