[lexical-selection] Bug Fix: Preserve mixed-block content when wrapping selections #9668
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 373 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.354
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #9668"
general
weight: 0.35
wozhenbang2004
Description
When a block holds text directly next to nested blocks,
$wrapNodescan assign overlapping wrapping units. Moving a nested unit before its containing block can reorder text or leave the insertion anchor inside a new wrapper, producing a parent cycle.Resolve each unit to the outermost block whose children will move, cache those ancestor lookups, and choose the insertion anchor from the resolved unit. Covered empty blocks stay in the moved subtree. An uncovered empty first block keeps its own insertion anchor so preceding siblings stay in place. The existing handling of declared block containers and inline runs is retained.
Addresses issue #9665
Changeset
.changeset/tidy-box-wrap.mdadds a patch entry for@lexical/selection, with verification steps.Test plan
Before
The new regression tests against main
21bcf62:Both directions of the cycle case fail with
getParent called more than a million times: a cycle. Both text-order cases fail, the nested empty-block case fails, and the existing 500-document property reports seven failures, including three cycles.The review follow-up adds six focused empty-first-block cases. Against published head
0024dfcd, the sameWrapNodesBlockLeaf.test.ts --maxWorkers=1command reports4 failed | 15 passed (19): the Box/list forward/backward cases reproducet0, t3, t1instead oft0, t1, t3. Both covered-empty cases already pass.After
This includes forward/backward selections, horizontal rules, nested empty blocks, a wrapping element, attached selection points with valid offsets, and the existing seeded property test now enabled as a normal test. The six new cases also check the empty quote position and covered empty-node identity, parent and sibling order. Independent follow-up QA ran
WrapNodesBlockLeafandWrapNodesInlineContent: 2 files / 1535 tests passed. These runs contain no skipped or expected-failure tests.These checks were rerun for the follow-up and exited 0:
node_modules/.bin/tsc --noEmitnode_modules/.bin/tsc -p tsconfig.test.json --noEmitnode scripts/check-flow-types.mjs(Found 0 errors)node scripts/changesets/check.mjs(Changeset check passed: 68 pending changeset(s) valid.)The combined
pnpm run ci-checkattempt hit killed TypeScript processes (exit 137); the production/test type checks above were then run separately. The full unit/scripts-unit attempt was stopped (exit 130), so no full-suite result is claimed. Browser E2E tests were not run.