Skip to content
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

Prevent browser from loading dragged file when drag-area is missed #3222

Merged
merged 5 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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)

Expand Down
23 changes: 23 additions & 0 deletions app/assets/javascripts/components/disable_generic_dnd.js
Original file line number Diff line number Diff line change
@@ -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: Event) => {
e.preventDefault();
};

render() {
return null;
}
}
2 changes: 2 additions & 0 deletions app/assets/javascripts/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -113,6 +114,7 @@ class ReactRouter extends React.Component<Props> {
return (
<Router history={browserHistory}>
<Layout>
<DisableGenericDnd />
<Navbar isAuthenticated={isAuthenticated} />
<Content>
<Switch>
Expand Down