@@ -109,6 +109,20 @@ function ReorderableGrid(props) {
109
109
} ) ;
110
110
useDraggableCollection ( { } , dragState , ref ) ;
111
111
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
+
112
126
let dropState = useDroppableCollectionState ( {
113
127
collection : gridState . collection ,
114
128
selectionManager : gridState . selectionManager ,
@@ -118,26 +132,15 @@ function ReorderableGrid(props) {
118
132
}
119
133
120
134
return 'move' ;
121
- }
135
+ } ,
136
+ onDrop
122
137
} ) ;
123
138
124
139
let { collectionProps} = useDroppableCollection ( {
125
140
keyboardDelegate,
126
141
dropTargetDelegate : new ListDropTargetDelegate ( state . collection , ref ) ,
127
142
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
141
144
} , dropState , ref ) ;
142
145
143
146
let { gridProps} = useGrid ( {
0 commit comments