1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00

fix firefox simulate click issue

This commit is contained in:
Tim Daubenschütz 2015-06-30 11:56:38 +02:00
parent e31b6f0108
commit 1976dee57a
2 changed files with 13 additions and 6 deletions

View File

@ -4,8 +4,10 @@ import React from 'react';
import FileDragAndDropPreviewIterator from './file_drag_and_drop_preview_iterator'; import FileDragAndDropPreviewIterator from './file_drag_and_drop_preview_iterator';
let ReactTestUtils = React.addons.TestUtils;
// Taken from: https://github.com/fedosejev/react-file-drag-and-drop // Taken from: https://github.com/fedosejev/react-file-drag-and-drop
var FileDragAndDrop = React.createClass({ let FileDragAndDrop = React.createClass({
propTypes: { propTypes: {
className: React.PropTypes.string, className: React.PropTypes.string,
onDragStart: React.PropTypes.func, onDragStart: React.PropTypes.func,
@ -116,10 +118,16 @@ var FileDragAndDrop = React.createClass({
return; return;
} }
// Simulate click on hidden file input // Firefox only recognizes the simulated mouse click if bubbles is set to true,
var event = document.createEvent('HTMLEvents'); // but since Google Chrome propagates the event much further than needed, we
event.initEvent('click', false, true); // need to stop propagation as soon as the event is created
this.refs.fileinput.getDOMNode().dispatchEvent(event); var evt = new MouseEvent("click", {
view: window,
bubbles: true,
cancelable: true,
});
evt.stopPropagation();
this.refs.fileinput.getDOMNode().dispatchEvent(evt);
}, },
render: function () { render: function () {

View File

@ -32,7 +32,6 @@ let FileDragAndDropPreview = React.createClass({
// don't run it // don't run it
// On the other hand, if the files progress is not yet at a 100%, // On the other hand, if the files progress is not yet at a 100%,
// just run fineuploader.cancel // just run fineuploader.cancel
console.log(this.props.file);
if(this.props.handleDeleteFile && this.props.file.progress === 100) { if(this.props.handleDeleteFile && this.props.file.progress === 100) {
this.props.handleDeleteFile(this.props.file.id); this.props.handleDeleteFile(this.props.file.id);
} else if(this.props.handleCancelFile && this.props.file.progress !== 100) { } else if(this.props.handleCancelFile && this.props.file.progress !== 100) {