File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed
Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ export class DraggingPositionEvaluation {
2222
2323 private offset : 'bottom' | 'top' | undefined ;
2424
25- private indentation : number ;
25+ private indentation : number | undefined ;
2626
2727 private targetItem : LinearItem ;
2828
@@ -82,6 +82,10 @@ export class DraggingPositionEvaluation {
8282 * the x-coordinate of the mouse allows to reparent upwards.
8383 */
8484 private maybeReparentUpwards ( ) : DraggingPosition | undefined {
85+ if ( this . indentation === undefined ) {
86+ return undefined ;
87+ }
88+
8589 const treeLinearItems = this . env . linearItems [ this . treeId ] ;
8690 const deepestDepth = treeLinearItems [ this . linearIndex ] . depth ;
8791
Original file line number Diff line number Diff line change @@ -80,13 +80,15 @@ export const useDraggingPosition = () => {
8080 const targetLinearItem = treeLinearItems [ linearIndex ] ;
8181 const targetItem = env . items [ targetLinearItem . item ] ;
8282
83- const indentation = Math . min (
84- Math . max (
85- Math . floor ( ( e . clientX - treeBb . left ) / env . renderDepthOffset ) ,
86- 0
87- ) ,
88- targetLinearItem . depth
89- ) ;
83+ const indentation = ! env . renderDepthOffset
84+ ? undefined
85+ : Math . min (
86+ Math . max (
87+ Math . floor ( ( e . clientX - treeBb . left ) / env . renderDepthOffset ) ,
88+ 0
89+ ) ,
90+ targetLinearItem . depth
91+ ) ;
9092
9193 let offset : 'top' | 'bottom' | undefined ;
9294
Original file line number Diff line number Diff line change @@ -523,5 +523,7 @@ export interface LiveDescriptors {
523523export type HoveringPosition = {
524524 linearIndex : number ;
525525 offset : 'bottom' | 'top' | undefined ;
526- indentation : number ;
526+
527+ // is undefined if tree renderDepthOffset is not set or zero
528+ indentation : number | undefined ;
527529} ;
You can’t perform that action at this time.
0 commit comments