react-component / react-component/tree
onDrop's arguments dropPosition not equal allowDrop's arguments dropPosition
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 490
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 5
Description
import RcTree from "rc-tree";
import "rc-tree/assets/index.css";
const treeData = [
{
title: "title0",
key: "key0"
},
{
title: "title1",
key: "key1"
},
{
title: "title2",
key: "key2"
},
{
title: "title3",
key: "key3"
},
{
title: "title4",
key: "key4"
},
{
title: "title5",
key: "key5",
children: [
{
title: "title4-0",
key: "key4-0"
},
{
title: "title4-1",
key: "key4-1"
},
{
title: "title4-2",
key: "key4-2"
},
{
title: "title4-3",
key: "key4-3"
}
]
},
{
title: "title6",
key: "key6"
}
];
export default function App() {
return (
<RcTree
allowDrop={(params) => {
if (Math.random() > 0.99) {
console.log("allow drop:", params);
}
return true;
}}
onDrop={(params) => {
console.log("on Drop:", params);
}}
draggable
defaultExpandAll
treeData={treeData}
/>
);
}
try to drag title4-3 as first child(before title4-0), and see console
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction and compare the parameters logged by allowDrop and onDrop while dragging title4-3 before title4-0. Trace the drag-and-drop entry point used by RcTree, then verify that both callbacks report the same dropPosition for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100