@@ -240,7 +240,7 @@ let onInsert = async (e) => {
240
240
} = e ;
241
241
242
242
let processedItems = await Promise .all (
243
- items .map (async item => JSON .parse (await item .getText (acceptedDragTypes [ 0 ] )))
243
+ items .map (async item => JSON .parse (await item .getText (' adobe-app ' )))
244
244
);
245
245
246
246
if (target .dropPosition === ' before' ) {
@@ -262,7 +262,7 @@ let onItemDrop = async (e) => {
262
262
target
263
263
} = e ;
264
264
let processedItems = await Promise .all (
265
- items .map (async item => JSON .parse (await item .getText (acceptedDragTypes [ 0 ] )))
265
+ items .map (async item => JSON .parse (await item .getText (' adobe-app ' )))
266
266
);
267
267
let targetItem = list .getItem (target .key );
268
268
list .update (target .key , {... targetItem , childNodes: [... targetItem .childNodes , ... processedItems ]});
@@ -291,15 +291,17 @@ function DroppableList() {
291
291
{id: ' k' , type: ' folder' , name: ' Apps' , childNodes: []}
292
292
]
293
293
});
294
- let acceptedDragTypes = [ ' adobe-app ' ];
294
+
295
295
let {dragAndDropHooks} = useDragAndDrop ({
296
+ acceptedDragTypes: [' adobe-app' ],
297
+ shouldAcceptItemDrop : (target ) => !! list .getItem (target .key ).childNodes ,
296
298
onInsert : async (e ) => {
297
299
let {
298
300
items,
299
301
target
300
302
} = e ;
301
303
let processedItems = await Promise .all (
302
- items .map (async item => JSON .parse (await item .getText (acceptedDragTypes [ 0 ] )))
304
+ items .map (async item => JSON .parse (await item .getText (' adobe-app ' )))
303
305
);
304
306
305
307
if (target .dropPosition === ' before' ) {
@@ -314,13 +316,11 @@ function DroppableList() {
314
316
target
315
317
} = e ;
316
318
let processedItems = await Promise .all (
317
- items .map (async item => JSON .parse (await item .getText (acceptedDragTypes [ 0 ] )))
319
+ items .map (async item => JSON .parse (await item .getText (' adobe-app ' )))
318
320
);
319
321
let targetItem = list .getItem (target .key );
320
322
list .update (target .key , {... targetItem , childNodes: [... targetItem .childNodes , ... processedItems ]});
321
- },
322
- acceptedDragTypes ,
323
- shouldAcceptItemDrop : (target ) => !! list .getItem (target .key ).childNodes
323
+ }
324
324
});
325
325
326
326
return (
@@ -355,6 +355,8 @@ see the [API section](#low-level-drop-handlers-and-options) below and the `useDr
355
355
The ListView below allows external directories to be dropped at its root level or between existing items. Files of a specific type can be dropped on certain pre-existing directories only.
356
356
357
357
``` tsx example
358
+ import {DIRECTORY_DRAG_TYPE } from ' @react-spectrum/dnd' ;
359
+
358
360
function DroppableListLowLevelAPI() {
359
361
let list = useListData ({
360
362
initialItems: [
0 commit comments