Skip to content

Commit

Permalink
fix: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jia-nan committed Feb 1, 2025
1 parent ea157c0 commit 0968ea4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
29 changes: 19 additions & 10 deletions src/AjaxUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
props.onBatchStart?.(
fileList.map(({ origin, parsedFile }) => ({ file: origin, parsedFile })),
);
fileList.filter(file => file.parsedFile !== null).forEach(file => post(file));
fileList
.filter(file => file.parsedFile !== null)
.forEach(file => {
post(file);
});
});
};

Expand Down Expand Up @@ -259,14 +263,8 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
}
};

const cls = classnames(prefixCls, className, {
[`${prefixCls}-disabled`]: disabled,
});

// because input don't have directory/webkitdirectory type declaration
const dirProps: any = directory
? { directory: 'directory', webkitdirectory: 'webkitdirectory' }
: {};
const dirProps = directory ? { directory: 'directory', webkitdirectory: 'webkitdirectory' } : {};

const events = disabled
? {}
Expand All @@ -277,11 +275,18 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
onMouseLeave,
onDrop: onFileDrop,
onDragOver: onFileDrop,
tabIndex: hasControlInside ? undefined : 0,
};

return (
<Tag {...events} className={cls} role={hasControlInside ? undefined : 'button'} style={style}>
<Tag
{...events}
style={style}
role={disabled || hasControlInside ? undefined : 'button'}
tabIndex={disabled || hasControlInside ? undefined : 0}
className={classnames(prefixCls, className, {
[`${prefixCls}-disabled`]: disabled,
})}
>
<input
{...pickAttrs(otherProps, { aria: true, data: true })}
id={id}
Expand All @@ -308,4 +313,8 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
);
};

if (process.env.NODE_ENV !== 'production') {
AjaxUploader.displayName = 'AjaxUploader';
}

export default AjaxUploader;
4 changes: 4 additions & 0 deletions src/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ const Upload: React.FC<Readonly<UploadProps>> = props => {
);
};

if (process.env.NODE_ENV !== 'production') {
Upload.displayName = 'Upload';
}

export default Upload;
4 changes: 2 additions & 2 deletions src/uid.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const now = +new Date();
const now = Date.now();

let index = 0;

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

Expand Down

0 comments on commit 0968ea4

Please sign in to comment.