Repository navigation
fix(sender): preserve slots for text selection deletion - #2033
advance-hub wants to merge 3 commits into
Conversation
Why: - Backspace treated a non-collapsed selection as a caret at offset zero. - When the selection edge touched a slot, Sender removed the slot and prevented the browser from deleting the selected text. What: - Limit preceding-slot removal to collapsed ranges. - Add a regression test for a backwards text selection adjacent to 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.
|
| Layer / File(s) | Summary |
|---|---|
退格删除条件与回归测试 packages/x/components/sender/components/SlotTextArea.tsx, packages/x/components/sender/__tests__/slot.test.tsx |
SlotTextArea 仅在选区折叠时通过 Backspace 删除前置 slot 或 skill。测试验证折叠选区可删除 skill 或 slot 并调用一次 onChange;非折叠选区会保留 slot,且不调用 onChange。 |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related issues
- ant-design/x#1906:该问题报告选中文本删除触及 slot 时会先删除 slot。本次变更针对非折叠选区增加保护。
Suggested reviewers: nrps9909
Merge Risk: 
Minimal · up to cab9d
-
The slot-preservation regression is covered, and no outstanding issue was identified. This change is ready to merge after normal checks.
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
PR
#1906的编码要求是修复 Sender slot 模式下删除非折叠文本选区时误删 slot 或阻止正常删除的问题。SlotTextArea.tsx在退格删除分支中仅对range?.collapsed的光标执行前置 slot/skill 删除。非折叠选区交由浏览器处理。slot.test.tsx新增了选区边缘接触 slot 的回归测试,并验证 slot 保留且不触发onChange。测试还覆盖了折叠光标删除前置 slot 和 skill 的原有行为。现有证据支持该问题已实现修复。
Full details: Docstring Coverage
-
Explanation
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)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
一只小兔轻敲退格键,
折叠光标旁,slot 轻轻离开。
选中文本时,slot 留在原地,
skill 删除后,文本依然清晰。
测试点点头,回调记录一次。
月光下,小兔收起键盘。<fixed_issue_severity>Medium</fixed_issue_severity>
Comment @coderabbitai help to get the list of available commands.
nrps9909
left a comment
There was a problem hiding this comment.
Reviewed exact head 189de5b3d21d6792b68920cc95440697c58e6aa1 against base 25aad7b9c13abeb165466d53b375d0f2ffe81fa0.
The collapsed-range guard is the right boundary. Reverting only that guard makes the submitted backwards-selection regression fail exactly as intended: the keydown is prevented at the focus edge and the adjacent slot enters the deletion path. Restoring this head makes the complete Sender slot file pass 23/23. I also added a temporary complementary probe for a collapsed caret at offset zero; all 24 tests passed, and the preceding slot was still removed with one onChange, so the existing caret behavior is preserved.
Additional exact-head validation:
- package TypeScript
--noEmitpasses - Biome check passes on both changed files
git diff --checkpasses- GitHub reports the head mergeable and all current remote checks green
The repository has no lockfile, so I ran the behavioral suite with an internally consistent @ant-design/cssinjs dependency pair and reran TypeScript after deduping the currently resolved pair; this avoids treating an unrelated transform-cache/dependency-topology issue as a Sender failure.
AI assistance disclosure: Codex helped inspect the exact diff and run the red/green and complementary probes; I verified the SHA, source paths, outputs, static checks, and live status directly.
Approved.
Bundle ReportChanges will decrease total bundle size by 2.4MB (-41.12%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: antdx-array-pushAssets Changed:
view changes for bundle: x-markdown-array-pushAssets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2033 +/- ##
==========================================
+ Coverage 97.07% 97.25% +0.18%
==========================================
Files 159 163 +4
Lines 5777 6305 +528
Branches 1702 1878 +176
==========================================
+ Hits 5608 6132 +524
- Misses 167 171 +4
Partials 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Why
In Sender slot mode, Backspace treated a non-collapsed text selection as a caret at offset zero. When the selection edge touched a slot, Sender removed the slot and prevented the browser from deleting the selected text.
Fixes #1906.
What changed
Verification
--noEmitcheck passed.git diff --checkpassed.Before / After
Before: Backspace removes the adjacent slot while the selected text remains.
before.mp4
After: Backspace deletes the selected text while preserving the slot.
after.mp4
Changelog: Fix Sender slot mode deleting the adjacent slot before a selected text range.
Summary by CodeRabbit