You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Payment due 1-25][$250] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area #33820
Version Number: 1.4.20-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: Applause - Internal Team Slack conversation:
Action Performed:
Go to workspace chat > + > Request money
Go to Scan
Open a file explorer window next the the drag & drop area
Drag a file over the area and remove it from the area repeatedly (and very quickly)
Expected Result:
"Drop file here" modal will dimiss when the file is no longer dragged over the area
Actual Result:
"Drop file here" modal does not dismiss when the file is no longer dragged over the area
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
changed the title [-]Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/-][+][$500] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/+]on Jan 1, 2024
Please re-state the problem that we are trying to solve in this issue.
"Drop file here" modal does not dismiss when file is no longer dragged over the area
What is the root cause of that problem?
The drag-and-drop hook is based on a reference counter to do the overlay works well, but when we use a component or window that lives outside the browser we get this bug because the counter increases more than expected.
What changes do you think we should make in order to solve the problem?
We should modify the drag-and-drop hook to take into consideration scenarios when we are dragging outside the drag-and-drop zone to decrease the reference counter.
The code should be like:
case DRAG_OVER_EVENT:
handleDragEvent(event);
if (isDraggingOver && dragCounter.current > 1) {
dragCounter.current--;
}
break;
// This solution is borrowed from this SO: https://stackoverflow.com/questions/7110353/html5-dragleave-fired-when-hovering-a-child-element
// This is necessary because dragging over children will cause dragleave to execute on the parent.
// You can think of this counter as a stack. When a child is hovered over we push an element onto the stack.
// Then we only process the dragleave event if the count is 0, because it means that the last element (the parent) has been popped off the stack.
constdragCounter=useRef(0);
In short, when you move from one element to another element, the ENTER (for the new element) and LEAVE (for the current element) events will be called. So, the ENTER and LEAVE events should cancel out each other. However, if the element disappears, the LEAVE event won't be called.
In our case, if we start dragging the file to the instruction view, let's say the "Upload receipt" text,
the ENTER event will be triggered for the "Upload receipt" text. Then, the drop file here view shows AND the instruction view disappears.
// You can think of this counter as a stack. When a child is hovered over we push an element onto the stack.
// Then we only process the dragleave event if the count is 0, because it means that the last element (the parent) has been popped off the stack.
We can think of this counter as a stack, so we will decrease dragCounter when dragLeave event is fired.
Before users drag file, we have 3 components in IOU scan view (one of them is instruction view) -> dragEnter is triggered 3 times -> dragCounter =3
When users start to drag file, the dragging view is present and the instruction view disappears so the dragLeave for instruction view is never triggered -> dragCounter just decease to 1 when users leave the window
-> isDraggingOver is not set to false
What changes do you think we should make in order to solve the problem?
We should not lean on dragCounter because of the above reason. To solve the problem dragging over children will cause dragleave to execute on the parent. we need to check if the currentTarget contains relatedTarget in dragLeave then we will early return
case DRAG_LEAVE_EVENT:
if (event?.currentTarget?.contains(event.relatedTarget)) {
return;
}
setIsDraggingOver(false);
changed the title [-][$500] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/-][+][Payment due 1-25-24][$500] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/+]on Jan 26, 2024
changed the title [-][Payment due 1-25-24][$500] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/-][+][Payment due 1-25-24][$250] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/+]on Jan 26, 2024
changed the title [-][Payment due 1-25-24][$250] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/-][+][Payment due 1-25][$250] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/+]on Jan 26, 2024
Activity
[-]Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/-][+][$500] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/+]melvin-bot commentedon Jan 1, 2024
Job added to Upwork: https://www.upwork.com/jobs/~01d19df269e522389b
melvin-bot commentedon Jan 1, 2024
Triggered auto assignment to @Christinadobrzyn (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Jan 1, 2024
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Jan 1, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt (
External)samilabud commentedon Jan 1, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
"Drop file here" modal does not dismiss when file is no longer dragged over the area
What is the root cause of that problem?
The drag-and-drop hook is based on a reference counter to do the overlay works well, but when we use a component or window that lives outside the browser we get this bug because the counter increases more than expected.
What changes do you think we should make in order to solve the problem?
We should modify the drag-and-drop hook to take into consideration scenarios when we are dragging outside the drag-and-drop zone to decrease the reference counter.
The code should be like:
Result - after changes:
drag-and-drop.test.after.changes.mp4
bernhardoj commentedon Jan 2, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
The scan request drop view doesn't disappear after we stop the drag.
What is the root cause of that problem?
This can easily be reproduced when you start dragging your file to the instruction view (that is the Upload receipt text and image).
Screen.Recording.2024-01-02.at.12.18.07.mov
The drop file here view will be shown if
isDraggingOverstate is true.App/src/components/DragAndDrop/Consumer/index.tsx
Lines 7 to 18 in fe49e4f
The
isDraggingOverstate itself will be set based ondragCountervalue.App/src/hooks/useDragAndDrop.ts
Lines 84 to 99 in fe49e4f
The problem in this issue is, that the
isDraggingOvervalue is stuck attrueeven though we already stopped the drag because thedragCounteris not 0.The reason we use drag counter is explained in the comment here.
App/src/hooks/useDragAndDrop.ts
Lines 33 to 37 in fe49e4f
In short, when you move from one element to another element, the ENTER (for the new element) and LEAVE (for the current element) events will be called. So, the ENTER and LEAVE events should cancel out each other. However, if the element disappears, the LEAVE event won't be called.
In our case, if we start dragging the file to the instruction view, let's say the "Upload receipt" text,

the ENTER event will be triggered for the "Upload receipt" text. Then, the drop file here view shows AND the instruction view disappears.
App/src/pages/iou/request/step/IOURequestStepScan/index.js
Line 325 in cb4fc64
Thus, the LEAVE event for "Upload receipt" text is never fired leaving 1 drag counter behind.
What changes do you think we should make in order to solve the problem?
The simplest solution is to make it invisible by setting the opacity to 0 when dragging instead of unmounting it from the view.
What alternative solutions did you explore? (Optional)
The other way is:
tienifr commentedon Jan 2, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
"Drop file here" modal does not dismiss when the file is no longer dragged over the area
What is the root cause of that problem?
We're updating
isDraggingOverto false ifdragCounteris 0App/src/hooks/useDragAndDrop.ts
Lines 35 to 36 in cb4fc64
We can think of this counter as a stack, so we will decrease
dragCounterwhendragLeaveevent is fired.Before users drag file, we have 3 components in IOU scan view (one of them is instruction view) ->
dragEnteris triggered 3 times -> dragCounter =3When users start to drag file, the dragging view is present and the instruction view disappears so the
dragLeavefor instruction view is never triggered -> dragCounter just decease to 1 when users leave the window-> isDraggingOver is not set to false
What changes do you think we should make in order to solve the problem?
We should not lean on
dragCounterbecause of the above reason. To solve the problemdragging over children will cause dragleave to execute on the parent.we need to check if the currentTarget contains relatedTarget indragLeavethen we will early returnRef: https://stackoverflow.com/a/54271161
What alternative solutions did you explore? (Optional)
NA
Result
Screen.Recording.2024-01-02.at.11.45.38.mov
15 remaining items
situchan commentedon Jan 11, 2024
Seems like regression came from this issue
s77rt commentedon Jan 22, 2024
s77rt commentedon Jan 22, 2024
@Christinadobrzyn Can you please add the
Awaiting Paymentlabel here? Looks like Melvin is OOOChristinadobrzyn commentedon Jan 23, 2024
@s77rt can you confirm if we're working on this PR - #23589 or if this needs to be paid out now?
s77rt commentedon Jan 23, 2024
@Christinadobrzyn Ah sorry for not clarifying. This should be paid on 25th. The payment due here should be $250.
(No work is being done on any PR. All is done already)
[-][$500] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/-][+][Payment due 1-25-24][$500] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/+][-][Payment due 1-25-24][$500] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/-][+][Payment due 1-25-24][$250] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/+]melvin-bot commentedon Jan 26, 2024
Upwork job price has been updated to $250
[-][Payment due 1-25-24][$250] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/-][+][Payment due 1-25][$250] Scan - "Drop file here" modal does not dismiss when file is no longer dragged over the area[/+]Christinadobrzyn commentedon Jan 26, 2024
paying this out
Payouts due:
Contributor: $250 @tienifr (paid in Upwork)
Contributor+: $250 @s77rt (paid in Upwork)
Eligible for 50% #urgency bonus? NA
Upwork job is here.
No regression test. Closing this out but let me know if you need anything!