File tree 3 files changed +16
-1
lines changed
3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -231,6 +231,15 @@ export const useOnDragOverTreeHandler = (
231
231
232
232
let draggingPosition : DraggingPosition ;
233
233
234
+ // Used to move the dragBetweenLine component down to the actual
235
+ // end of the target item's contents, see #148
236
+ const targetItemEndOfContents =
237
+ offset === 'top'
238
+ ? 0
239
+ : linearItems [ treeId ]
240
+ . slice ( linearIndex + 1 )
241
+ . findIndex ( item => item . depth <= depth ) ;
242
+
234
243
if ( offset ) {
235
244
draggingPosition = {
236
245
targetType : 'between-items' ,
@@ -242,6 +251,7 @@ export const useOnDragOverTreeHandler = (
242
251
// childIndex: environment.items[parent.item].children!.indexOf(targetItem.item) + (offset === 'top' ? 0 : 1),
243
252
childIndex : newChildIndex ,
244
253
linePosition : offset ,
254
+ targetItemEndOfContents,
245
255
} ;
246
256
} else {
247
257
draggingPosition = {
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ export const DragBetweenLine: React.FC<{
18
18
return null ;
19
19
}
20
20
21
+ const position =
22
+ ( draggingPosition ?. linearIndex ?? 0 ) +
23
+ ( draggingPosition . targetItemEndOfContents ?? 0 ) ;
24
+
21
25
const lineProps : HTMLProps < any > = {
22
26
onDragOver : e => e . preventDefault ( ) , // Allow dropping
23
27
} ;
@@ -28,7 +32,7 @@ export const DragBetweenLine: React.FC<{
28
32
position : 'absolute' ,
29
33
left : '0' ,
30
34
right : '0' ,
31
- top : `${ ( draggingPosition ?. linearIndex ?? 0 ) * itemHeight } px` ,
35
+ top : `${ position * itemHeight } px` ,
32
36
} }
33
37
>
34
38
{ renderers . renderDragBetweenLine ( {
Original file line number Diff line number Diff line change @@ -323,6 +323,7 @@ export interface DraggingPositionBetweenItems extends AbstractDraggingPosition {
323
323
childIndex : number ;
324
324
linePosition : 'top' | 'bottom' ;
325
325
parentItem : TreeItemIndex ;
326
+ targetItemEndOfContents : number ;
326
327
}
327
328
328
329
export interface DraggingPositionRoot extends AbstractDraggingPosition {
You can’t perform that action at this time.
0 commit comments