-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Warn user before closing when uploading a file on a upload only link #16984
Conversation
Signed-off-by: Julius Härtl <jus@bitgrid.net>
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! :)
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!
@@ -120,6 +130,9 @@ | |||
e.preventDefault(); | |||
$('#public-upload #emptycontent input').focus().trigger('click'); | |||
}); | |||
window.onbeforeunload = function() { |
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.
From https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#Syntax
Typically, it is better to use window.addEventListener() and the beforeunload event, instead of onbeforeunload.
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.
Ah yes! Especially since we remove inline scripts with csp :)
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.
So merge or?
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.
Dunno. @juliushaertl which one should we use? :)
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.
I don't have a strong oppinion, this code is mainly a copy of what we use here:
server/apps/files/js/file-upload.js
Line 1291 in 07c3665
window.onbeforeunload = function() { |
So I'd say lets get it in and we can cleanup if we might refactor at some point, as I don't see any downside of that code for now
Backport to 17? |
Yes, I'd say so. |
/backport to stable17 |
backport to stable17 in #17034 |
Make sure the browser shows a warning that a upload is still ongoing when uploading files though a drop only link.