Skip to content

[lexical-playground] Bug Fix: Clear inline font-size when converting to heading#8800

Merged
etrepum merged 2 commits into
facebook:mainfrom
mayrang:fix/5509-heading-font-size
Jul 9, 2026
Merged

[lexical-playground] Bug Fix: Clear inline font-size when converting to heading#8800
etrepum merged 2 commits into
facebook:mainfrom
mayrang:fix/5509-heading-font-size

Conversation

@mayrang

@mayrang mayrang commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

Converting text with a custom font-size to a heading (H1/H2/H3) had no visible effect on the text size. The inline font-size style on the text nodes took CSS precedence over the heading class's font-size, so the heading always appeared at whatever size the user had set manually.

After $setBlocksType converts the block, $patchStyleText now clears the font-size inline style so the heading class controls the size. Other inline styles (bold, color, font-family) are preserved since they don't conflict with the heading's core visual identity.

Closes #5509

Test plan

  • Manual playground: type text → set font-size to 20px → select → convert to H1 → text renders at H1's 24px, not 20px
  • Manual playground: convert H1 back to paragraph → text uses default paragraph size
  • Manual playground: text with mixed sizes (some default, some custom) → convert to H2 → all text renders at H2 size
  • Undo (Cmd+Z) after heading conversion restores both block type and font-size in one step
  • tsc / eslint / prettier clean

…to heading

When converting text to a heading, inline font-size styles on text nodes
took CSS precedence over the heading class font-size, making the heading
format visually ineffective. Clear the font-size inline style after
applying the heading block type so the heading CSS class controls the
size.

Closes facebook#5509
@vercel

vercel Bot commented Jul 7, 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 Jul 7, 2026 4:24am
lexical-playground Ready Ready Preview Jul 7, 2026 4:24am

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 Jul 7, 2026
@mayrang mayrang marked this pull request as draft July 7, 2026 04:15
$setBlocksType calls replace() which clones and replaces the editor
selection, leaving the original selection variable stale. Using it
with $patchStyleText caused a "no common ancestor" error when the
selection spanned decorator nodes.
@etrepum etrepum added this pull request to the merge queue Jul 9, 2026
Merged via the queue into facebook:main with commit a5a1779 Jul 9, 2026
50 checks passed
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: Headings broken for sizes other than 15

2 participants