Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# History
----

- Add `openFileDialogOnEnter`.

### 2.6.0 / 2018-09-21

- Add `openFileDialogOnClick`.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ React.render(<Upload />, container);
|customRequest | function | null | provide an override for the default xhr behavior for additional customization|
|withCredentials | boolean | false | ajax upload with cookie send |
|openFileDialogOnClick | boolean | true | |
|openFileDialogOnEnter | boolean | true | useful for drag only upload as it does not trigger on enter key |

#### onError arguments

Expand Down
6 changes: 4 additions & 2 deletions src/AjaxUploader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class AjaxUploader extends Component {
onProgress: PropTypes.func,
withCredentials: PropTypes.bool,
openFileDialogOnClick: PropTypes.bool,
openFileDialogOnEnter: PropTypes.bool,
}

state = { uid: getUid() }
Expand Down Expand Up @@ -200,15 +201,16 @@ class AjaxUploader extends Component {
const {
component: Tag, prefixCls, className, disabled, id,
style, multiple, accept, children, directory, openFileDialogOnClick,
openFileDialogOnEnter,
} = this.props;
const cls = classNames({
[prefixCls]: true,
[`${prefixCls}-disabled`]: disabled,
[className]: className,
});
const events = disabled ? {} : {
onClick: openFileDialogOnClick ? this.onClick : () => { },
onKeyDown: this.onKeyDown,
onClick: openFileDialogOnClick ? this.onClick: () => { },
onKeyDown: openFileDialogOnEnter ? this.onKeyDown: () => { },
onDrop: this.onFileDrop,
onDragOver: this.onFileDrop,
tabIndex: '0',
Expand Down
2 changes: 2 additions & 0 deletions src/Upload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Upload extends Component {
withCredentials: PropTypes.bool,
supportServerRender: PropTypes.bool,
openFileDialogOnClick: PropTypes.bool,
openFileDialogOnEnter: PropTypes.bool,
}

static defaultProps = {
Expand All @@ -55,6 +56,7 @@ class Upload extends Component {
customRequest: null,
withCredentials: false,
openFileDialogOnClick: true,
openFileDialogOnEnter: true,
}

state = {
Expand Down