File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed
packages/core/src/features/drag-and-drop Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @headless-tree/core " : patch
3+ ---
4+
5+ Added ` isUnorderedDragTarget ` as alternative to ` isDragTarget ` for easier detection of drag type
Original file line number Diff line number Diff line change @@ -332,6 +332,13 @@ export const dragAndDropFeature: FeatureImplementation = {
332332 return target ? target . item . getId ( ) === item . getId ( ) : false ;
333333 } ,
334334
335+ isUnorderedDragTarget : ( { tree, item } ) => {
336+ const target = tree . getDragTarget ( ) ;
337+ return target
338+ ? ! isOrderedDragTarget ( target ) && target . item . getId ( ) === item . getId ( )
339+ : false ;
340+ } ,
341+
335342 isDragTargetAbove : ( { tree, item } ) => {
336343 const target = tree . getDragTarget ( ) ;
337344
Original file line number Diff line number Diff line change @@ -108,7 +108,13 @@ export type DragAndDropFeatureDef<T> = {
108108 ) => Record < string , any > ;
109109 } ;
110110 itemInstance : {
111+ /** Checks if the user is dragging in a way which makes this the new parent of the dragged items, either by dragging on top of
112+ * this item, or by dragging inbetween children of this item. See @{isUnorderedDragTarget} if the latter is undesirable. */
111113 isDragTarget : ( ) => boolean ;
114+
115+ /** As opposed to @{isDragTarget}, this will not be true if the target is inbetween children of this item. This returns only true
116+ * if the user is dragging directly on top of this item. */
117+ isUnorderedDragTarget : ( ) => boolean ;
112118 isDragTargetAbove : ( ) => boolean ;
113119 isDragTargetBelow : ( ) => boolean ;
114120 isDraggingOver : ( ) => boolean ;
You can’t perform that action at this time.
0 commit comments