mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 01:25:17 +01:00
fix firefox simulate click issue
This commit is contained in:
parent
e31b6f0108
commit
1976dee57a
@ -4,8 +4,10 @@ import React from 'react';
|
||||
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
|
||||
var FileDragAndDrop = React.createClass({
|
||||
let FileDragAndDrop = React.createClass({
|
||||
propTypes: {
|
||||
className: React.PropTypes.string,
|
||||
onDragStart: React.PropTypes.func,
|
||||
@ -116,10 +118,16 @@ var FileDragAndDrop = React.createClass({
|
||||
return;
|
||||
}
|
||||
|
||||
// Simulate click on hidden file input
|
||||
var event = document.createEvent('HTMLEvents');
|
||||
event.initEvent('click', false, true);
|
||||
this.refs.fileinput.getDOMNode().dispatchEvent(event);
|
||||
// Firefox only recognizes the simulated mouse click if bubbles is set to true,
|
||||
// but since Google Chrome propagates the event much further than needed, we
|
||||
// need to stop propagation as soon as the event is created
|
||||
var evt = new MouseEvent("click", {
|
||||
view: window,
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
});
|
||||
evt.stopPropagation();
|
||||
this.refs.fileinput.getDOMNode().dispatchEvent(evt);
|
||||
},
|
||||
|
||||
render: function () {
|
||||
|
@ -32,7 +32,6 @@ let FileDragAndDropPreview = React.createClass({
|
||||
// don't run it
|
||||
// On the other hand, if the files progress is not yet at a 100%,
|
||||
// just run fineuploader.cancel
|
||||
console.log(this.props.file);
|
||||
if(this.props.handleDeleteFile && this.props.file.progress === 100) {
|
||||
this.props.handleDeleteFile(this.props.file.id);
|
||||
} else if(this.props.handleCancelFile && this.props.file.progress !== 100) {
|
||||
|
Loading…
Reference in New Issue
Block a user