Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions packages/@react-aria/dnd/stories/Reorderable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ function ReorderableGrid(props) {
});
useDraggableCollection({}, dragState, ref);

let onDrop = async (e) => {
if (e.target.type !== 'root' && e.target.dropPosition !== 'on' && props.onMove) {
let keys = [];
for (let item of e.items) {
if (item.kind === 'text' && item.types.has(dragType)) {
let key = JSON.parse(await item.getText(dragType));
keys.push(key);
}
}

props.onMove(keys, e.target);
}
};

let dropState = useDroppableCollectionState({
collection: gridState.collection,
selectionManager: gridState.selectionManager,
Expand All @@ -118,26 +132,15 @@ function ReorderableGrid(props) {
}

return 'move';
}
},
onDrop
});

let {collectionProps} = useDroppableCollection({
keyboardDelegate,
dropTargetDelegate: new ListDropTargetDelegate(state.collection, ref),
onDropActivate: chain(action('onDropActivate'), console.log),
onDrop: async e => {
if (e.target.type !== 'root' && e.target.dropPosition !== 'on' && props.onMove) {
let keys = [];
for (let item of e.items) {
if (item.kind === 'text' && item.types.has(dragType)) {
let key = JSON.parse(await item.getText(dragType));
keys.push(key);
}
}

props.onMove(keys, e.target);
}
}
onDrop
}, dropState, ref);

let {gridProps} = useGrid({
Expand Down