phphe / vue-draggable-nested-tree

Vue2 draggable tree component
https://hetree.phphe.com/
MIT License
344 stars 62 forks source link

Drag to reorder donot work at deepest level (my fix in PR attached) #27

Open flight9 opened 6 years ago

flight9 commented 6 years ago

At level 2 all nodes can be re-ordered by drag&drop, but at level 3 it seems not. I found only the first position which is next to the upper level, is allowed to drop. see below. level-3-912104040124

I've limited the max level to 3, using the codes in MaxLevel, is that relative to this problem?

version: vue-draggable-nested-tree 2.1.6

flight9 commented 6 years ago

I found, on current version, if a node is 'droppable=false', another node can't be dropped behind it, even they are at the save level. (我发现现在的版本, 如果一个节点是'droppable=false', 另一个节点就不能放在其后面, 即便他们是在同一个层级里。)

I think what the 'droppable' property means is to limit whether other nodes can be placed as its children nodes, not to limit whether them are as its siblings. Is that correct? (我想一个节点的'droppable'属性是为了限制其他节点是否能被作为子节点放在其下层, 而不是限制其他节点作为兄弟节点, 不知是否是这样理解?)

(PS. 附上了中文, 避免我的英语产生歧义)

phphe commented 6 years ago

我可能要周末才能看看

flight9 commented 6 years ago

@phphe 谢谢回复

flight9 commented 6 years ago

我发现, 源代码中下面这些行: https://github.com/phphe/vue-draggable-nested-tree/blob/3ca6ce57cf6c4cfb0142c2d2ca5ebc8fc4812c70/src/components/autoMoveDragPlaceHolder.js#L362 https://github.com/phphe/vue-draggable-nested-tree/blob/3ca6ce57cf6c4cfb0142c2d2ca5ebc8fc4812c70/src/components/autoMoveDragPlaceHolder.js#L368 https://github.com/phphe/vue-draggable-nested-tree/blob/3ca6ce57cf6c4cfb0142c2d2ca5ebc8fc4812c70/src/components/autoMoveDragPlaceHolder.js#L371 都改为:

targets['after'](info);

可以修复上述问题, 但我不确定 if-else 层次中是否还有其他分支影响到这个问题。