Skip to content

Commit 13941cf

Browse files
authored
Update reorderable story to fit updated DnD api (#3838)
1 parent 0182ad0 commit 13941cf

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

packages/@react-aria/dnd/stories/Reorderable.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ function ReorderableGrid(props) {
109109
});
110110
useDraggableCollection({}, dragState, ref);
111111

112+
let onDrop = async (e) => {
113+
if (e.target.type !== 'root' && e.target.dropPosition !== 'on' && props.onMove) {
114+
let keys = [];
115+
for (let item of e.items) {
116+
if (item.kind === 'text' && item.types.has(dragType)) {
117+
let key = JSON.parse(await item.getText(dragType));
118+
keys.push(key);
119+
}
120+
}
121+
122+
props.onMove(keys, e.target);
123+
}
124+
};
125+
112126
let dropState = useDroppableCollectionState({
113127
collection: gridState.collection,
114128
selectionManager: gridState.selectionManager,
@@ -118,26 +132,15 @@ function ReorderableGrid(props) {
118132
}
119133

120134
return 'move';
121-
}
135+
},
136+
onDrop
122137
});
123138

124139
let {collectionProps} = useDroppableCollection({
125140
keyboardDelegate,
126141
dropTargetDelegate: new ListDropTargetDelegate(state.collection, ref),
127142
onDropActivate: chain(action('onDropActivate'), console.log),
128-
onDrop: async e => {
129-
if (e.target.type !== 'root' && e.target.dropPosition !== 'on' && props.onMove) {
130-
let keys = [];
131-
for (let item of e.items) {
132-
if (item.kind === 'text' && item.types.has(dragType)) {
133-
let key = JSON.parse(await item.getText(dragType));
134-
keys.push(key);
135-
}
136-
}
137-
138-
props.onMove(keys, e.target);
139-
}
140-
}
143+
onDrop
141144
}, dropState, ref);
142145

143146
let {gridProps} = useGrid({

0 commit comments

Comments
 (0)