fix(sender): delete newlines before slots - #2034
Conversation
Why: - Chromium leaves a block wrapper when Backspace removes the leading break from a line that starts with a non-editable slot. - The remaining wrapper keeps the visual newline even though the break node is gone. What: - Detect the collapsed caret at the affected slot line boundary. - Unwrap the line, preserve the slot nodes, and restore the caret before the slot. - Add a regression test for Enter then Backspace before a slot. Testing: - Sender slot Jest suite (23 tests) - TypeScript noEmit check - Biome check and git diff --check - Real Chromium before/after interaction
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughSender 新增 Chromium 下的退格处理:删除 slot 前的换行块,提升 slot 节点,恢复光标并触发一次 ChangesSender slot 换行删除
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized Sender fix removes the unwanted newline before a slot while preserving the slot and caret; no actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nrps9909
left a comment
There was a problem hiding this comment.
Reviewed exact head 8d052ad against base 25aad7b.
The Chromium newline repair is narrowly gated to a collapsed Backspace selection at offset 0 in a direct child block whose leading nodes are BR plus a registered slot. It removes only that BR and wrapper, preserves the remaining nodes in order, restores the caret immediately before the first slot, and emits one value change.
Validation performed:
- Reverted the new repair branch locally: the submitted regression test failed at the expected event/default-prevention assertion.
- Exact head Sender slot suite: 23/23 passed.
- Temporary complementary probes passed for multiple slots with intervening/trailing text, exact DOM order preservation, caret range at the original line index, one onChange, and non-collapsed selection remaining untouched.
- packages/x TypeScript noEmit passed.
- Biome passed on both changed files.
- git diff --check passed.
- Live PR head rechecked before review and still matches the tested SHA; current remote checks are green.
AI assistance disclosure: Codex was used to inspect the exact diff, run the red/green validation and complementary boundary probes, and draft this review. I verified the reported commands and outcomes.
Why
In Chromium, pressing Enter immediately before a non-editable Sender slot creates a new block that starts with
<br>. Backspace removes the break node but leaves the block wrapper, so the visual newline cannot be deleted.Fixes #1889.
What changed
Verification
--noEmitcheck passed.git diff --checkpassed.Before / After
Before: Backspace removes
<br>, but the block wrapper keeps the newline.before.mp4
After: Backspace merges the line while preserving the slot and caret position.
after.mp4
Changelog: Fix Sender slot mode being unable to delete a newline immediately before a slot.
Summary by CodeRabbit