@@ -29,9 +29,8 @@ const getHoveringPosition = (
29
29
if ( linearIndex > treeLinearItems . length - 1 ) {
30
30
return {
31
31
linearIndex : treeLinearItems . length - 1 ,
32
- targetItem : treeLinearItems [ treeLinearItems . length - 1 ] . item ,
33
32
offset : 'bottom' ,
34
- targetLinearItem : treeLinearItems [ treeLinearItems . length - 1 ] ,
33
+ veryBottom : true ,
35
34
} as const ;
36
35
}
37
36
@@ -51,7 +50,7 @@ const getHoveringPosition = (
51
50
offset = 'bottom' ;
52
51
}
53
52
54
- return { linearIndex, offset, targetItem , targetLinearItem } ;
53
+ return { linearIndex, offset } ;
55
54
} ;
56
55
57
56
const useIsDescendant = ( ) => {
@@ -137,7 +136,8 @@ export const useOnDragOverTreeHandler = (
137
136
return ;
138
137
}
139
138
140
- let { linearIndex, offset } = getHoveringPosition (
139
+ // eslint-disable-next-line prefer-const
140
+ let { linearIndex, offset, veryBottom } = getHoveringPosition (
141
141
e . clientY ,
142
142
treeBb . top ,
143
143
itemHeight ,
@@ -151,7 +151,7 @@ export const useOnDragOverTreeHandler = (
151
151
152
152
const nextDragCode = outsideContainer
153
153
? 'outside'
154
- : `${ treeId } ${ linearIndex } ${ offset ?? '' } ` ;
154
+ : `${ treeId } ${ linearIndex } ${ offset ?? '' } ${ veryBottom && 'vb' } ` ;
155
155
156
156
if ( lastDragCode === nextDragCode ) {
157
157
return ;
@@ -244,15 +244,24 @@ export const useOnDragOverTreeHandler = (
244
244
245
245
let draggingPosition : DraggingPosition ;
246
246
247
- if ( offset ) {
247
+ if ( veryBottom ) {
248
+ const { rootItem } = trees [ treeId ] ;
249
+ draggingPosition = {
250
+ targetType : 'between-items' ,
251
+ treeId,
252
+ parentItem : rootItem ,
253
+ depth : 0 ,
254
+ linearIndex : linearIndex + 1 ,
255
+ childIndex : items [ rootItem ] . children ?. length ?? 0 ,
256
+ linePosition : 'bottom' ,
257
+ } ;
258
+ } else if ( offset ) {
248
259
draggingPosition = {
249
260
targetType : 'between-items' ,
250
261
treeId,
251
262
parentItem : parent . item ,
252
263
depth : targetItem . depth ,
253
264
linearIndex : linearIndex + ( offset === 'top' ? 0 : 1 ) ,
254
- // childIndex: linearIndex - parentLinearIndex - 1 + (offset === 'top' ? 0 : 1),
255
- // childIndex: environment.items[parent.item].children!.indexOf(targetItem.item) + (offset === 'top' ? 0 : 1),
256
265
childIndex : newChildIndex ,
257
266
linePosition : offset ,
258
267
} ;
0 commit comments