From d9bf4529fdcbd65573b57e598b370f938a8241f8 Mon Sep 17 00:00:00 2001 From: Philipp Otto Date: Thu, 13 Sep 2018 17:18:37 +0200 Subject: [PATCH 1/3] prevent browser from loading dragged file when drag-area is missed (fixes #3196) --- .../components/disable_generic_dnd.js | 23 +++++++++++++++++++ app/assets/javascripts/router.js | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 app/assets/javascripts/components/disable_generic_dnd.js diff --git a/app/assets/javascripts/components/disable_generic_dnd.js b/app/assets/javascripts/components/disable_generic_dnd.js new file mode 100644 index 00000000000..819e649f931 --- /dev/null +++ b/app/assets/javascripts/components/disable_generic_dnd.js @@ -0,0 +1,23 @@ +// @flow + +import React from "react"; + +export default class DisableGenericDnd extends React.Component<{}> { + componentDidMount() { + window.addEventListener("dragover", this.preventDefault, false); + window.addEventListener("drop", this.preventDefault, false); + } + + componentWillUnmount() { + window.removeEventListener("dragover", this.preventDefault); + window.removeEventListener("drop", this.preventDefault); + } + + preventDefault = e => { + e.preventDefault(); + }; + + render() { + return null; + } +} diff --git a/app/assets/javascripts/router.js b/app/assets/javascripts/router.js index eeea5bf1887..48ae53d97cc 100644 --- a/app/assets/javascripts/router.js +++ b/app/assets/javascripts/router.js @@ -12,6 +12,7 @@ import { ControlModeEnum } from "oxalis/constants"; import { APITracingTypeEnum } from "admin/api_flow_types"; import { getAnnotationInformation } from "admin/admin_rest_api"; import SecuredRoute from "components/secured_route"; +import DisableGenericDnd from "components/disable_generic_dnd"; import Navbar from "navbar"; import { Imprint, Privacy } from "components/legal"; @@ -113,6 +114,7 @@ class ReactRouter extends React.Component { return ( + From 17b29ed17034278d481e6918a542d52fe65c8ba5 Mon Sep 17 00:00:00 2001 From: Philipp Otto Date: Thu, 13 Sep 2018 17:37:49 +0200 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c983a934a6e..b48fe1e87a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md). - The welcome header will now also show on the default page if there are no existing organisations. [#3133](https://github.com/scalableminds/webknossos/pull/3133) - Simplified the sharing of tracings. Users can simply copy the active URL from the browser's URL bar to share a tracing (assuming the tracing is public). [#3176](https://github.com/scalableminds/webknossos/pull/3176) - Improved general performance of the tracing view by leveraging web workers. [#3162](https://github.com/scalableminds/webknossos/pull/3162) +- Improved overall drag-and-drop behavior by preventing the browser from opening the dragged file when the actual drag target was missed. [#3222](https://github.com/scalableminds/webknossos/pull/3222) - The checkboxes in the user list view will clear now after the experience domains of users have been changed. [#3178](https://github.com/scalableminds/webknossos/pull/3178) - Resetting a user's task requires a confirmation now. [#3181](https://github.com/scalableminds/webknossos/pull/3181) From 9b81fe566b5f73912784f56318353725bd35a7cf Mon Sep 17 00:00:00 2001 From: Philipp Otto Date: Mon, 17 Sep 2018 08:39:45 +0200 Subject: [PATCH 3/3] add missing type annotation --- app/assets/javascripts/components/disable_generic_dnd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/components/disable_generic_dnd.js b/app/assets/javascripts/components/disable_generic_dnd.js index 819e649f931..8e570e4c901 100644 --- a/app/assets/javascripts/components/disable_generic_dnd.js +++ b/app/assets/javascripts/components/disable_generic_dnd.js @@ -13,7 +13,7 @@ export default class DisableGenericDnd extends React.Component<{}> { window.removeEventListener("drop", this.preventDefault); } - preventDefault = e => { + preventDefault = (e: Event) => { e.preventDefault(); };