Skip to content

Commit

Permalink
fix: Upload don't support onMouseEnter/onMouseLeave
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Jun 18, 2020
1 parent e0c73c1 commit 472a3d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# History
----

### 3.2.0

- support `onClick` `onMouseEnter` `onMouseLeave`.

### 3.1.0

- `data` could return Promise.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-upload",
"version": "3.1.4",
"version": "3.2.0",
"description": "upload ui component for react",
"keywords": [
"react",
Expand Down
14 changes: 10 additions & 4 deletions src/AjaxUploader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@ class AjaxUploader extends Component {
this.reset();
}

onClick = () => {
onClick = (e) => {
const el = this.fileInput;
if (!el) {
return;
}
const { children } = this.props;
const { children, onClick } = this.props;
if (children && children.type === 'button') {
el.parentNode.focus();
el.parentNode.querySelector('button').blur();
}
el.click();
if (onClick) {
onClick(e);
}
}

onKeyDown = e => {
Expand Down Expand Up @@ -216,6 +219,7 @@ class AjaxUploader extends Component {
const {
component: Tag, prefixCls, className, disabled, id,
style, multiple, accept, children, directory, openFileDialogOnClick,
onMouseEnter, onMouseLeave,
...otherProps
} = this.props;
const cls = classNames({
Expand All @@ -224,8 +228,10 @@ class AjaxUploader extends Component {
[className]: className,
});
const events = disabled ? {} : {
onClick: openFileDialogOnClick ? this.onClick : () => { },
onKeyDown: openFileDialogOnClick ? this.onKeyDown : () => { },
onClick: openFileDialogOnClick ? this.onClick : () => {},
onKeyDown: openFileDialogOnClick ? this.onKeyDown : () => {},
onMouseEnter,
onMouseLeave,
onDrop: this.onFileDrop,
onDragOver: this.onFileDrop,
tabIndex: '0',
Expand Down

0 comments on commit 472a3d6

Please sign in to comment.