Skip to content

Commit

Permalink
fix(Tree): can`t drag external element
Browse files Browse the repository at this point in the history
  • Loading branch information
myronliu347 committed Feb 22, 2019
1 parent d6a9afc commit a247a09
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/tree/demo/draggable.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class Demo extends React.Component {
}

onDrop(info) {
if (!info.dragNode) {
return;
}
const dragKey = info.dragNode.props.eventKey;
const dropKey = info.node.props.eventKey;
const dropPosition = info.dropPosition;
Expand Down
4 changes: 2 additions & 2 deletions src/tree/view/tree.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ export default class Tree extends Component {
handleDragEnter(e, node) {
const dragOverNodeKey = node.props.eventKey;
this.dropPosition = this.getDropPosition(e, node);
if (this.dragNode.props.eventKey === dragOverNodeKey && this.dropPosition === 0) {
if (this.dragNode && this.dragNode.props.eventKey === dragOverNodeKey && this.dropPosition === 0) {
this.setState({
dragOverNodeKey: null
});
Expand Down Expand Up @@ -835,7 +835,7 @@ export default class Tree extends Component {
}

handleDrop(e, node) {
if (isDescendantOrSelf(this._k2n[this.dragNode.props.eventKey].pos, this._k2n[node.props.eventKey].pos)) {
if (this.dragNode && isDescendantOrSelf(this._k2n[this.dragNode.props.eventKey].pos, this._k2n[node.props.eventKey].pos)) {
return;
}

Expand Down

0 comments on commit a247a09

Please sign in to comment.