Repository navigation
Conversation
…the active selection ## Description $patchStyleText accepts a selection, but its text-node iterator reads the active selection instead. A detached range or node selection can therefore style nothing or modify unrelated selected text. Even a collapsed target can style an unrelated active range. Share the existing iterator through a private helper that receives its selection explicitly. $patchStyleText uses its argument; the public $forEachSelectedTextNode continues to use the active selection with no API change. This fix is based on main and is independent of the caret text-slice changes in meta#9261. ## Test plan ### Before ```sh node node_modules/vitest/vitest.mjs run --project unit packages/lexical-selection/src/__tests__/unit/PatchStyleDetachedSelection.test.ts --maxWorkers=2 ``` ```text Test Files 1 failed (1) Tests 10 failed | 2 passed (12) ``` ### After ```sh node node_modules/vitest/vitest.mjs run --project unit packages/lexical-selection --maxWorkers=2 ``` ```text Test Files 7 passed (7) Tests 331 passed (331) ``` Coverage includes whole/partial/collapsed ranges and node selections with no active selection, an unrelated caret, or an unrelated range. Checks verify that unrelated text and active endpoints remain unchanged. Test TypeScript, changed-file ESLint/Prettier, and git diff --check pass. Browser tests were not run.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Author
|
Superseded by #9261, which now includes this fix together with caret-based endpoint repair and tests for backward detached ranges, repaired selection points, and repeated style patches. |
This branch was successfully deployed
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
$patchStyleTextaccepts a selection, but its text-node iterator reads the active selection instead. A detached range or node selection can therefore style nothing or modify unrelated selected text. Even a collapsed target can style an unrelated active range.Share the existing iterator through a private helper that receives its selection explicitly.
$patchStyleTextuses its argument; the public$forEachSelectedTextNodecontinues to use the active selection with no API change. This fix is based on main and is independent of the caret text-slice changes in #9261.Test plan
Additional unit test coverage