-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable Drag & Drop by default #24536
Conversation
@allroundexperts Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@allroundexperts Drag & Drop doesn't work in Android Chrome. Screen.Recording.2023-08-14.at.8.35.09.PM.mov |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-08-16.at.12.10.29.AM.movMobile Web - ChromeN/A Mobile Web - SafariN/A DesktopScreen.Recording.2023-08-16.at.12.16.34.AM.moviOSN/A AndroidN/A |
web/index.html
Outdated
function dropDragListener(){ | ||
event.preventDefault(); | ||
event.dataTransfer.dropEffect = 'none'; | ||
} | ||
document.addEventListener('dragover', dropDragListener); | ||
document.addEventListener('dragenter', dropDragListener); | ||
document.addEventListener('dragleave', dropDragListener); | ||
document.addEventListener('drop', dropDragListener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ginsuma Instead of here, can't we add it inside our App
file? This would be more of a react way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allroundexperts We should add it for the web platform only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a platform specific hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allroundexperts I moved it to inside App.js
file.
src/App.js
Outdated
useEffect(() => { | ||
const platform = getPlatform(); | ||
if (platform !== CONST.PLATFORM.WEB && platform !== CONST.PLATFORM.DESKTOP) { | ||
return; | ||
} | ||
document.addEventListener('dragover', dropDragListener); | ||
document.addEventListener('dragenter', dropDragListener); | ||
document.addEventListener('dragleave', dropDragListener); | ||
document.addEventListener('drop', dropDragListener); | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We never use platform specific code inline like this @ginsuma. Please create separate files for each platform.
src/App.js
Outdated
useEffect(() => { | ||
const platform = getPlatform(); | ||
if (platform !== CONST.PLATFORM.WEB && platform !== CONST.PLATFORM.DESKTOP) { | ||
return; | ||
} | ||
document.addEventListener('dragover', dropDragListener); | ||
document.addEventListener('dragenter', dropDragListener); | ||
document.addEventListener('dragleave', dropDragListener); | ||
document.addEventListener('drop', dropDragListener); | ||
setDefaultDragDropEvent(); | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about creating a hook instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allroundexperts I created useDefaultDragAndDrop
hook.
useEffect(() => { | ||
document.addEventListener('dragover', dropDragListener); | ||
document.addEventListener('dragenter', dropDragListener); | ||
document.addEventListener('dragleave', dropDragListener); | ||
document.addEventListener('drop', dropDragListener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to unsubscribe
these listeners.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏
const dropDragListener = (event) => { | ||
event.preventDefault(); | ||
// eslint-disable-next-line no-param-reassign | ||
event.dataTransfer.dropEffect = 'none'; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to define this inside the effect as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏
@ginsuma I'm encountering the following bug sometimes when I'm dragging over a no drop zone and then opening the LHN. Screen.Recording.2023-08-16.at.12.42.21.AM.movCan you please confirm / fix? |
It would also be good if you can add more comprehensive test steps! |
@allroundexperts I'm sorry. Could you tell me clearly what the bug is in the video? Screen.Recording.2023-08-16.at.1.33.21.PM.mov |
@ginsuma Check the video from 38s onwards. Notice that after dragging, opening RHN closes it automatically. |
@allroundexperts I can't reprocedure it 😥. |
I wasn't able to reproduce accurately as well. But it happens only some times. |
Seems like a race condition to me. |
@allroundexperts Does it happen only for RHP? Have you tried to open an attachment modal instead? We need more clues. |
@ginsuma Can you merge main? I'll test this once more. |
@allroundexperts I merged it and did a test one more time but couldn't reprocedure. Screen.Recording.2023-08-21.at.12.57.12.PM.mp4 |
@ginsuma Can you please merge main again? Thanks! |
@allroundexperts I merged. |
@ginsuma You need to sync your fork's main with Expensify's main and then merge your fork's main into this PR. I see that this PR is still not in sync with main. |
@allroundexperts That's what I did, but there was an issue with Mapbox config a few hours ago. Now it's okay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
It's still happening but I was able to reproduce it on main as well. So we're good here! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good and tests well on web.
@deetergp looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/deetergp in version: 1.3.57-0 🚀
|
🚀 Deployed to staging by https://github.com/deetergp in version: 1.3.58-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.57-6 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.58-5 🚀
|
Details
Disable Drag & Drop by default.
Fixed Issues
$ #22218
PROPOSAL: #22218 (comment)
Tests
Offline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
6a53cdb9-17cd-4a2a-9a76-d7ea2aece48e.mp4
Mobile Web - Safari
original-17D3F1F9-832F-47C5-9CE5-F8B4CFD377F7.mp4
Mobile Web - Chrome
Screen.Recording.2023-08-14.at.8.35.09.PM.mov
Desktop
Screen.Recording.2023-08-14.at.7.58.06.PM.mov
iOS
Not support drag & drop on the native app.
Android
Not support drag & drop on the native app.