Only show upload modal when drag event contains files (#2409)

* fix(upload): Only show upload modal when drag even contains files

* fix(firefox): Close drag window ondragend also

Do not only end drag styles on drag leave, but also on drag end. Fixes firefox bug. #687

* fix(drag-modal): Remove drag modal trigger cruft

* fix(upload-modal): Allow close with escape button
This commit is contained in:
Stephen Burgess
2017-04-24 13:19:33 -05:00
committed by Eugen
parent e59f5c8e13
commit 2d99c962df
2 changed files with 40 additions and 3 deletions

View File

@ -4,6 +4,34 @@ import { FormattedMessage } from 'react-intl';
class UploadArea extends React.PureComponent {
constructor (props, context) {
super(props, context);
this.handleKeyUp = this.handleKeyUp.bind(this);
}
handleKeyUp (e) {
e.preventDefault();
e.stopPropagation();
const keyCode = e.keyCode
if (this.props.active) {
switch(keyCode) {
case 27:
this.props.onClose();
break;
}
}
}
componentDidMount () {
window.addEventListener('keyup', this.handleKeyUp, false);
}
componentWillUnmount () {
window.removeEventListener('keyup', this.handleKeyUp);
}
render () {
const { active } = this.props;
@ -24,7 +52,8 @@ class UploadArea extends React.PureComponent {
}
UploadArea.propTypes = {
active: PropTypes.bool
active: PropTypes.bool,
onClose: PropTypes.func
};
export default UploadArea;