Skip to content

Commit

Permalink
follow up
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
  • Loading branch information
igorDykhta committed Mar 1, 2025
1 parent 9ef3fb5 commit 728b518
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/src/common/file-uploader/file-drop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ const FileDrop = ({
// the event bubbles up to the frame. By keeping count of how many "dragenters" we get, we can tell if they are still
// "draggingOverFrame" (b/c you get one "dragenter" initially, and one "dragenter"/one "dragleave" for every bubble)
// This is far better than a "dragover" handler, which would be calling `setState` continuously.
setFrameDragCounter(frameDragCounter + (event.type === 'dragenter' ? 1 : -1));
const newDragCounterValue = frameDragCounter + (event.type === 'dragenter' ? 1 : -1);
setFrameDragCounter(newDragCounterValue);

if (frameDragCounter === 1) {
if (newDragCounterValue === 1) {
setDraggingOverFrame(true);
if (onFrameDragEnter) onFrameDragEnter(event);
return;
}

if (frameDragCounter === 0) {
if (newDragCounterValue === 0) {
setDraggingOverFrame(false);
if (onFrameDragLeave) onFrameDragLeave(event);
return;
Expand Down

0 comments on commit 728b518

Please sign in to comment.