-
-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Description
currently, the second argument, target: DragTarget from onDraop is typed as below.
export type DragTarget<T> = {
item: ItemInstance<T>;
childIndex: number;
insertionIndex: number;
dragLineIndex: number;
dragLineLevel: number;
} | {
item: ItemInstance<T>;
};This introduces laibility over "insertionIndex" in target syntax for property check, which can break without error in future updates (as the package updates)
onDrop(items, target) {
const b_index = "insertionIndex" in target ? target.insertionIndex : 0;
console.log("drop", items, target.item.getItemName());
},Introduce a flag or type, and make the properties always available 0 or null. (or even -1)
export type DragTarget<T> = {
item: ItemInstance<T>;
childIndex: number;
insertionIndex: number;
dragLineIndex: number | null;
dragLineLevel: number | null;
};I don't know the details behind this design, but Having childIndex insertionIndex as always available, fallback to 0 or -1 makes good sense.
Metadata
Metadata
Assignees
Labels
No labels