Skip to content

[lexical-playground] Fix : On pressing clear formatting clears text alignment even when no formatting is applied to text#8237

Open
Jynx2004 wants to merge 9 commits intofacebook:mainfrom
Jynx2004:format_issue_fix
Open

[lexical-playground] Fix : On pressing clear formatting clears text alignment even when no formatting is applied to text#8237
Jynx2004 wants to merge 9 commits intofacebook:mainfrom
Jynx2004:format_issue_fix

Conversation

@Jynx2004
Copy link
Contributor

Description

Updated clear-formatting to detect the “no formatting” case by checking selection.extract() instead of comparing anchor/focus. This ensures alignment is cleared even when the selection is collapsed and no text formatting is present.

Closes #7383

lexical-format.mp4

Test plan

All the existing unit tests passed . No new tests created.

@vercel
Copy link

vercel bot commented Mar 18, 2026

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Mar 19, 2026 9:41am
lexical-playground Ready Ready Preview, Comment Mar 19, 2026 9:41am

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 18, 2026
Copy link
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.

This PR needs tests to demonstrate that it solves the issue

@Jynx2004
Copy link
Contributor Author

This PR needs tests to demonstrate that it solves the issue

I have added the unit test to check this functionality

Copy link
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.

I don't think this is quite a complete solution, it's a bit greedy in that it will always clear formatting from the parent even if you've only selected some of the text. I think the block formatting should only be cleared if the block is selected, or all of its contents are selected.

@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label 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.

Bug: [lexical-playground] clear-formatting doesn't clear text-left/right/center alignment when no formatting to text

2 participants