@@ -25,7 +25,8 @@ class StorageItem extends React.Component {
25
25
const { storage } = this . props
26
26
27
27
this . state = {
28
- isOpen : ! ! storage . isOpen
28
+ isOpen : ! ! storage . isOpen ,
29
+ draggedOver : null
29
30
}
30
31
}
31
32
@@ -245,14 +246,20 @@ class StorageItem extends React.Component {
245
246
}
246
247
}
247
248
248
- handleDragEnter ( e ) {
249
- e . dataTransfer . setData ( 'defaultColor' , e . target . style . backgroundColor )
250
- e . target . style . backgroundColor = 'rgba(129, 130, 131, 0.08)'
249
+ handleDragEnter ( e , key ) {
250
+ e . preventDefault ( )
251
+ if ( this . state . draggedOver === key ) { return }
252
+ this . setState ( {
253
+ draggedOver : key
254
+ } )
251
255
}
252
256
253
257
handleDragLeave ( e ) {
254
- e . target . style . opacity = '1'
255
- e . target . style . backgroundColor = e . dataTransfer . getData ( 'defaultColor' )
258
+ e . preventDefault ( )
259
+ if ( this . state . draggedOver === null ) { return }
260
+ this . setState ( {
261
+ draggedOver : null
262
+ } )
256
263
}
257
264
258
265
dropNote ( storage , folder , dispatch , location , noteData ) {
@@ -277,8 +284,12 @@ class StorageItem extends React.Component {
277
284
}
278
285
279
286
handleDrop ( e , storage , folder , dispatch , location ) {
280
- e . target . style . opacity = '1'
281
- e . target . style . backgroundColor = e . dataTransfer . getData ( 'defaultColor' )
287
+ e . preventDefault ( )
288
+ if ( this . state . draggedOver !== null ) {
289
+ this . setState ( {
290
+ draggedOver : null
291
+ } )
292
+ }
282
293
const noteData = JSON . parse ( e . dataTransfer . getData ( 'note' ) )
283
294
this . dropNote ( storage , folder , dispatch , location , noteData )
284
295
}
@@ -305,16 +316,22 @@ class StorageItem extends React.Component {
305
316
< SortableStorageItemChild
306
317
key = { folder . key }
307
318
index = { index }
308
- isActive = { isActive }
319
+ isActive = { isActive || folder . key === this . state . draggedOver }
309
320
handleButtonClick = { ( e ) => this . handleFolderButtonClick ( folder . key ) ( e ) }
310
321
handleContextMenu = { ( e ) => this . handleFolderButtonContextMenu ( e , folder ) }
311
322
folderName = { folder . name }
312
323
folderColor = { folder . color }
313
324
isFolded = { isFolded }
314
325
noteCount = { noteCount }
315
- handleDrop = { ( e ) => this . handleDrop ( e , storage , folder , dispatch , location ) }
316
- handleDragEnter = { this . handleDragEnter }
317
- handleDragLeave = { this . handleDragLeave }
326
+ handleDrop = { ( e ) => {
327
+ this . handleDrop ( e , storage , folder , dispatch , location )
328
+ } }
329
+ handleDragEnter = { ( e ) => {
330
+ this . handleDragEnter ( e , folder . key )
331
+ } }
332
+ handleDragLeave = { ( e ) => {
333
+ this . handleDragLeave ( e , folder )
334
+ } }
318
335
/>
319
336
)
320
337
} )
0 commit comments