Skip to content

[lexical-playground] Bug fix: make clear formatting work on multiple paragraphs#8224

Merged
etrepum merged 7 commits intofacebook:mainfrom
dabrpio:fix/clear-formatting-button
Mar 16, 2026
Merged

[lexical-playground] Bug fix: make clear formatting work on multiple paragraphs#8224
etrepum merged 7 commits intofacebook:mainfrom
dabrpio:fix/clear-formatting-button

Conversation

@dabrpio
Copy link
Copy Markdown
Contributor

@dabrpio dabrpio commented Mar 15, 2026

Description

Clear formatting functionality does not work correctly when selection spans over more than one paragraph. This PR modifies clearFormatting function from packages/lexical-playground/src/plugins/ToolbarPlugin/utils.ts to fix this issue. This function was mainly operating on nodes from selection.getNodes(), now it leverages selection.extract().

Test plan

Added one test in packages/lexical-playground/__tests__/e2e/ClearFormatting.spec.mjs.

Before

lexical.-.clear.format.-.before.mp4

After

lexical.-.clear.format.-.after.mp4

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 15, 2026

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Mar 16, 2026 6:27pm
lexical-playground Ready Ready Preview, Comment Mar 16, 2026 6:27pm

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 Mar 15, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Mar 15, 2026
Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better for maintainability for these to use the public API. Whenever direct property access is used there's extra mental effort involved to ensure that either the intent is to inspect that exact version, the node is guaranteed to be the latest version, or at least the value should be identical to the latest version. Using the getter means that you don't have to do that analysis when reviewing the code.

Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something about the e2e test isn't working consistently in firefox and webkit, might want to try a different technique to make the selection

@etrepum etrepum added this pull request to the merge queue Mar 16, 2026
Merged via the queue into facebook:main with commit 5386635 Mar 16, 2026
34 checks passed
@etrepum etrepum mentioned this pull request Mar 19, 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