Skip to content

fix: preserve drag text set by consumers - #1071

Merged
yoyo837 merged 1 commit into
react-component:masterfrom
nrps9909:codex/preserve-drag-text-data
Aug 27, 2026
Merged

yoyo837 merged 1 commit into
react-component:masterfrom
nrps9909:codex/preserve-drag-text-data

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • initialize the Firefox text/plain drag fallback before invoking the consumer callback
  • allow onDragStart consumers to set or override the drag text payload
  • add a regression test for the call order and final DataTransfer value

Fixes #931.

Why

The Firefox fallback is still required, but applying it after the consumer callback overwrote any text/plain value set by the consumer. Initializing it first preserves the fallback while allowing the public callback to provide the actual payload.

Verification

  • exact-base regression failed before the fix: the custom value was followed by an empty fallback
  • TreeDraggable.spec.tsx: 37/37 tests passed
  • full suite: 14 suites, 225 tests, and 42 snapshots passed
  • TypeScript check passed
  • lint passed with 0 errors (11 existing warnings)
  • compile passed for ESM, CJS, declarations, and CSS
  • Prettier check passed for changed files
  • git diff --check passed

AI assistance disclosure: Codex was used to trace the drag-start flow, implement the focused fix, add the regression test, and run verification. The behavior and test results above were verified in this branch.

Summary by CodeRabbit

  • Bug 修复
    • 修复节点拖拽时自定义拖拽数据可能被默认逻辑覆盖的问题。
    • 现在可正确保留并读取自定义的 text/plain 拖拽内容。

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@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.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f40bce00-e9ec-4824-9ee7-6c9b83f63e4d

📥 Commits

Reviewing files that changed from the base of the PR and between 2492cbc and 1b87df9.

📒 Files selected for processing (2)
  • src/TreeNode.tsx
  • tests/TreeDraggable.spec.tsx

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

Tree 的拖拽开始流程先写入默认 text/plain 数据,再调用用户回调。新增测试验证用户设置的自定义拖拽数据不会被覆盖。

Changes

拖拽数据顺序

Layer / File(s) Summary
拖拽开始数据初始化与验证
src/TreeNode.tsx, tests/TreeDraggable.spec.tsx
onDragStart 先设置拖拽数据,再调用 context.onNodeDragStart。测试确认自定义 text/plain 数据仍可通过 dataTransfer.getData 读取。

Estimated code review effort: 2 (简单) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 1b87d

The change initializes the Firefox drag-text fallback before the consumer callback so consumer-provided text is preserved, with focused regression coverage and all reported checks passing; no actionable merge-blocking risk remains.

Suggested reviewers: emilyyyliu

Poem

小兔先写拖拽字,
回调随后稳稳至。
自定义数据不迷路,
测试轻敲确认时。
树影摇摇风里舞。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确描述了主要变更:保留消费者设置的拖拽文本。标题简洁、明确,并与代码和测试变更一致。
Linked Issues check ✅ Passed PR 将 Firefox 的 text/plain 回退数据设置移到 context.onNodeDragStart 之前,使消费者可以设置或覆盖拖拽文本。新增回归测试验证了回调顺序和最终 DataTransfer 值,满足 Issue #931 的编码目标。
Out of Scope Changes check ✅ Passed 代码变更仅调整 onDragStart 的执行顺序,并新增相关回归测试。所有变更都直接支持 Issue #931 和 PR 目标,未发现无关或超出范围的修改。
Docstring Coverage ✅ Passed 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…
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 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.84%. Comparing base (2492cbc) to head (1b87df9).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1071   +/-   ##
=======================================
  Coverage   99.84%   99.84%           
=======================================
  Files          15       15           
  Lines        1319     1319           
  Branches      400      400           
=======================================
  Hits         1317     1317           
  Misses          2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yoyo837
yoyo837 merged commit 71606f2 into react-component:master Aug 27, 2026
9 of 10 checks passed
aibayanyu20 added a commit to antdv-next/vue-components that referenced this pull request Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drag'n'drop with text/plain is currently prevented, and cannot be overriden

2 participants