fix: preserve nested first-child drop target - #1070
Conversation
|
@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. Walkthrough拖放逻辑新增 Changes拖放位置处理
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized fix preserves the correct nested first-child drop target and adds regression coverage for LTR and RTL behavior; no actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1070 +/- ##
==========================================
- Coverage 99.84% 99.84% -0.01%
==========================================
Files 15 15
Lines 1319 1318 -1
Branches 400 390 -10
==========================================
- Hits 1317 1316 -1
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
onDrop.nodewithdropToGap=trueand the correct relative positionallowDropcontractProblem
When the pointer enters the upper half of the first child of an expanded node,
calcDropPositioncurrently replaces that child with the previous flattened node, which is its parent. Dropping a sibling before that first child therefore reports the parent with an inside drop instead of the child with a gap drop.The root-level special case does not cover nested first children. Simply removing its level guard is insufficient because the target has already been replaced by the parent.
Solution
Detect the first-child upper-half case before the flattened-node fallback. This keeps the real hovered child as the abstract drop target, then reuses the existing before-target and
allowDrop({ dropPosition: -1 })path.Close ant-design/ant-design#59099.
Verification
0-0,dropToGap=false,dropPosition=0TreeDraggable.spec.tsx: 38/38 passedgit diff --check: passedI checked current open rc-tree PRs and found no duplicate implementation. The existing target-file overlaps are unrelated broad or stale changes.
AI assistance disclosure: Codex assisted with source tracing, the exact-base reproduction, implementation, validation, duplicate screening, and this description. The behavior and final diff were verified locally.
Summary by CodeRabbit
Bug 修复
测试