Skip to content

Commit 472a3d6

Browse files
committed
fix: Upload don't support onMouseEnter/onMouseLeave
ant-design/ant-design#25077
1 parent e0c73c1 commit 472a3d6

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# History
22
----
33

4+
### 3.2.0
5+
6+
- support `onClick` `onMouseEnter` `onMouseLeave`.
7+
48
### 3.1.0
59

610
- `data` could return Promise.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-upload",
3-
"version": "3.1.4",
3+
"version": "3.2.0",
44
"description": "upload ui component for react",
55
"keywords": [
66
"react",

src/AjaxUploader.jsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,20 @@ class AjaxUploader extends Component {
2929
this.reset();
3030
}
3131

32-
onClick = () => {
32+
onClick = (e) => {
3333
const el = this.fileInput;
3434
if (!el) {
3535
return;
3636
}
37-
const { children } = this.props;
37+
const { children, onClick } = this.props;
3838
if (children && children.type === 'button') {
3939
el.parentNode.focus();
4040
el.parentNode.querySelector('button').blur();
4141
}
4242
el.click();
43+
if (onClick) {
44+
onClick(e);
45+
}
4346
}
4447

4548
onKeyDown = e => {
@@ -216,6 +219,7 @@ class AjaxUploader extends Component {
216219
const {
217220
component: Tag, prefixCls, className, disabled, id,
218221
style, multiple, accept, children, directory, openFileDialogOnClick,
222+
onMouseEnter, onMouseLeave,
219223
...otherProps
220224
} = this.props;
221225
const cls = classNames({
@@ -224,8 +228,10 @@ class AjaxUploader extends Component {
224228
[className]: className,
225229
});
226230
const events = disabled ? {} : {
227-
onClick: openFileDialogOnClick ? this.onClick : () => { },
228-
onKeyDown: openFileDialogOnClick ? this.onKeyDown : () => { },
231+
onClick: openFileDialogOnClick ? this.onClick : () => {},
232+
onKeyDown: openFileDialogOnClick ? this.onKeyDown : () => {},
233+
onMouseEnter,
234+
onMouseLeave,
229235
onDrop: this.onFileDrop,
230236
onDragOver: this.onFileDrop,
231237
tabIndex: '0',

0 commit comments

Comments
 (0)