|
1 | 1 | /* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */
|
2 |
| -import type { ReactElement } from 'react'; |
3 |
| -import React, { Component } from 'react'; |
4 | 2 | import clsx from 'classnames';
|
5 | 3 | import pickAttrs from 'rc-util/lib/pickAttrs';
|
6 |
| -import defaultRequest from './request'; |
7 |
| -import getUid from './uid'; |
| 4 | +import React, { Component } from 'react'; |
8 | 5 | import attrAccept from './attr-accept';
|
9 |
| -import traverseFileTree from './traverseFileTree'; |
10 | 6 | import type {
|
11 |
| - UploadProps, |
| 7 | + BeforeUploadFileType, |
| 8 | + RcFile, |
12 | 9 | UploadProgressEvent,
|
| 10 | + UploadProps, |
13 | 11 | UploadRequestError,
|
14 |
| - RcFile, |
15 |
| - BeforeUploadFileType, |
16 | 12 | } from './interface';
|
| 13 | +import defaultRequest from './request'; |
| 14 | +import traverseFileTree from './traverseFileTree'; |
| 15 | +import getUid from './uid'; |
17 | 16 |
|
18 | 17 | interface ParsedFileInfo {
|
19 | 18 | origin: RcFile;
|
@@ -41,20 +40,23 @@ class AjaxUploader extends Component<UploadProps> {
|
41 | 40 | this.reset();
|
42 | 41 | };
|
43 | 42 |
|
44 |
| - onClick = (e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => { |
| 43 | + onClick = (event: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => { |
45 | 44 | const el = this.fileInput;
|
46 | 45 | if (!el) {
|
47 | 46 | return;
|
48 | 47 | }
|
49 |
| - const { children, onClick } = this.props; |
50 |
| - if (children && (children as ReactElement).type === 'button') { |
| 48 | + |
| 49 | + const target = event.target as HTMLElement; |
| 50 | + const { onClick } = this.props; |
| 51 | + |
| 52 | + if (target && target.tagName === 'BUTTON') { |
51 | 53 | const parent = el.parentNode as HTMLInputElement;
|
52 | 54 | parent.focus();
|
53 |
| - parent.querySelector('button').blur(); |
| 55 | + target.blur(); |
54 | 56 | }
|
55 | 57 | el.click();
|
56 | 58 | if (onClick) {
|
57 |
| - onClick(e); |
| 59 | + onClick(event); |
58 | 60 | }
|
59 | 61 | };
|
60 | 62 |
|
|
0 commit comments