-
Notifications
You must be signed in to change notification settings - Fork 16
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
IBX-8789: Fix double handling of file upload on window d&d #1332
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, { Component } from 'react'; | ||
import React, { Component, createRef } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { getTranslator } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; | ||
|
@@ -10,6 +10,7 @@ export default class DropAreaComponent extends Component { | |
super(props); | ||
|
||
this._refFileInput = null; | ||
this._refForm = createRef(); | ||
this.hasMultiMsgForFileSizes = this.props.maxFileSizes.length > 1; | ||
|
||
this.state = { | ||
|
@@ -104,6 +105,8 @@ export default class DropAreaComponent extends Component { | |
componentDidMount() { | ||
window.addEventListener('drop', this.props.preventDefaultAction, false); | ||
window.addEventListener('dragover', this.props.preventDefaultAction, false); | ||
|
||
this._refForm.current.addEventListener('drop', this.handleUpload, false); | ||
} | ||
|
||
componentWillUnmount() { | ||
|
@@ -122,7 +125,7 @@ export default class DropAreaComponent extends Component { | |
}); | ||
|
||
return ( | ||
<form className="c-drop-area" multiple={true} onDrop={this.handleUpload}> | ||
<form className="c-drop-area" onDrop={this.handleUpload} ref={this._refForm}> | ||
<div className="c-drop-area__message c-drop-area__message--main">{dropActionMessage}</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to use standard |
||
<div className="c-drop-area__message c-drop-area__message--separator">{separatorMessage}</div> | ||
<button | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,7 @@ export default class MultiFileUploadModule extends Component { | |
|
||
handleDropOnWindow(event) { | ||
this.preventDefaultAction(event); | ||
event.stopImmediatePropagation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: MFU is rendered twice in Sub-items, because extraAction items are rendered twice - once in the normal list and once in the popup list. Even though at the given time one of them always is hidden, they are always both rendered. |
||
|
||
const itemsToUpload = this.processUploadedFiles(event); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that
multiple
attribute does nothing and can be deleted.