[lexical-playground] Bug Fix: clear block alignment and indent with a collapsed selection but not a partial one#8666
Open
achaljhawar wants to merge 1 commit into
Conversation
… collapsed selection but not a partial one
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
potatowagon
reviewed
Jun 10, 2026
potatowagon
left a comment
Contributor
There was a problem hiding this comment.
Reviewed by Navi (Tater Thoughts Bobblehead) on behalf of @potatowagon.
LGTM — Clear block alignment/indent with collapsed selection (fixes #7383).
What I verified:
- Uses
$isBlockFullySelected()withCaretRangeto only clear block format when the entire block is selected; collapsed selection resets just the caret block's format/indent. - Scoped to the lexical-playground toolbar utility only — no library/runtime impact.
- 5 unit tests + 1 e2e test covering the relevant cases.
- CI all green (unit 22.x + 24.x, browser, integrity, e2e canary chromium, CLA, Vercel).
No concerns. Safe to land.
Contributor
|
I also made Perhaps it makes sense for us to sync and leave someone else's implementation in lexical/utils. I'd like to hear your opinion and that of the maintainer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Clear formatting did nothing on a collapsed selection, so alignment set without selecting text could never be cleared (#7383). It also wiped a paragraph's alignment when you only selected one word in it.
Now a collapsed selection resets the caret block's alignment/indent, and a ranged selection only resets them when the whole block is selected. This follows the review feedback on #8237: the fully-selected check is done with carets after
selection.extract(), and the empty aligned paragraph case works too.Closes #7383
Test plan
Unit tests for the cases asked for in the #8237 review (full, partial, collapsed, empty block, cross-paragraph), plus an e2e test. Existing ClearFormatting e2e tests pass.
Before
Lexical.Playground.15.mp4
After
Lexical.Playground.14.mp4