Skip to content
Snippets Groups Projects
Commit 131bae89 authored by blackle's avatar blackle
Browse files

Generate key for each input so we can upload the same file even after deleting

parent 2e71bb03
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,8 @@ const UploadButton = React.createClass({ ...@@ -11,7 +11,8 @@ const UploadButton = React.createClass({
propTypes: { propTypes: {
disabled: React.PropTypes.bool, disabled: React.PropTypes.bool,
onSelectFile: React.PropTypes.func.isRequired, onSelectFile: React.PropTypes.func.isRequired,
style: React.PropTypes.object style: React.PropTypes.object,
key: React.PropTypes.number
}, },
mixins: [PureRenderMixin], mixins: [PureRenderMixin],
...@@ -36,7 +37,7 @@ const UploadButton = React.createClass({ ...@@ -36,7 +37,7 @@ const UploadButton = React.createClass({
return ( return (
<div style={this.props.style}> <div style={this.props.style}>
<IconButton icon='photo' title={intl.formatMessage(messages.upload)} disabled={this.props.disabled} onClick={this.handleClick} size={24} /> <IconButton icon='photo' title={intl.formatMessage(messages.upload)} disabled={this.props.disabled} onClick={this.handleClick} size={24} />
<input ref={this.setRef} type='file' multiple={false} onChange={this.handleChange} disabled={this.props.disabled} style={{ display: 'none' }} /> <input key={this.props.key} ref={this.setRef} type='file' multiple={false} onChange={this.handleChange} disabled={this.props.disabled} style={{ display: 'none' }} />
</div> </div>
); );
} }
......
...@@ -4,6 +4,7 @@ import { uploadCompose } from '../../../actions/compose'; ...@@ -4,6 +4,7 @@ import { uploadCompose } from '../../../actions/compose';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
disabled: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size > 3 || state.getIn(['compose', 'media_attachments']).some(m => m.get('type') === 'video')), disabled: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size > 3 || state.getIn(['compose', 'media_attachments']).some(m => m.get('type') === 'video')),
key: Math.floor((Math.random() * 0x10000))
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment