Skip to content

Commit 0968ea4

Browse files
committed
fix: fix
1 parent ea157c0 commit 0968ea4

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

src/AjaxUploader.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
204204
props.onBatchStart?.(
205205
fileList.map(({ origin, parsedFile }) => ({ file: origin, parsedFile })),
206206
);
207-
fileList.filter(file => file.parsedFile !== null).forEach(file => post(file));
207+
fileList
208+
.filter(file => file.parsedFile !== null)
209+
.forEach(file => {
210+
post(file);
211+
});
208212
});
209213
};
210214

@@ -259,14 +263,8 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
259263
}
260264
};
261265

262-
const cls = classnames(prefixCls, className, {
263-
[`${prefixCls}-disabled`]: disabled,
264-
});
265-
266266
// because input don't have directory/webkitdirectory type declaration
267-
const dirProps: any = directory
268-
? { directory: 'directory', webkitdirectory: 'webkitdirectory' }
269-
: {};
267+
const dirProps = directory ? { directory: 'directory', webkitdirectory: 'webkitdirectory' } : {};
270268

271269
const events = disabled
272270
? {}
@@ -277,11 +275,18 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
277275
onMouseLeave,
278276
onDrop: onFileDrop,
279277
onDragOver: onFileDrop,
280-
tabIndex: hasControlInside ? undefined : 0,
281278
};
282279

283280
return (
284-
<Tag {...events} className={cls} role={hasControlInside ? undefined : 'button'} style={style}>
281+
<Tag
282+
{...events}
283+
style={style}
284+
role={disabled || hasControlInside ? undefined : 'button'}
285+
tabIndex={disabled || hasControlInside ? undefined : 0}
286+
className={classnames(prefixCls, className, {
287+
[`${prefixCls}-disabled`]: disabled,
288+
})}
289+
>
285290
<input
286291
{...pickAttrs(otherProps, { aria: true, data: true })}
287292
id={id}
@@ -308,4 +313,8 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
308313
);
309314
};
310315

316+
if (process.env.NODE_ENV !== 'production') {
317+
AjaxUploader.displayName = 'AjaxUploader';
318+
}
319+
311320
export default AjaxUploader;

src/Upload.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ const Upload: React.FC<Readonly<UploadProps>> = props => {
4343
);
4444
};
4545

46+
if (process.env.NODE_ENV !== 'production') {
47+
Upload.displayName = 'Upload';
48+
}
49+
4650
export default Upload;

src/uid.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const now = +new Date();
1+
const now = Date.now();
2+
23
let index = 0;
34

45
function uid() {
5-
// eslint-disable-next-line no-plusplus
66
return `rc-upload-${now}-${++index}`;
77
}
88

0 commit comments

Comments
 (0)