Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/AjaxUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ class AjaxUploader extends Component<UploadProps> {
onMouseEnter,
onMouseLeave,
hasControlInside,
type,
...otherProps
} = this.props;
const cls = clsx({
Expand All @@ -298,8 +299,10 @@ class AjaxUploader extends Component<UploadProps> {
onKeyDown: openFileDialogOnClick ? this.onKeyDown : () => {},
onMouseEnter,
onMouseLeave,
onDrop: this.onFileDrop,
onDragOver: this.onFileDrop,
...(type === 'drag' ? {
onDrop: this.onFileDrop,
onDragOver: this.onFileDrop,
} : {}),
tabIndex: hasControlInside ? undefined : '0',
};
return (
Expand Down
11 changes: 7 additions & 4 deletions tests/uploader.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ describe('uploader', () => {
});

it('drag to upload', done => {
const input = uploader.container.querySelector('input')!;
const { container } = render(<Upload {...props} type='drag' />);
const input = container.querySelector('input')!;

const files = [
{
Expand Down Expand Up @@ -243,7 +244,8 @@ describe('uploader', () => {
});

it('drag unaccepted type files to upload will not trigger onStart', done => {
const input = uploader.container.querySelector('input')!;
const { container } = render(<Upload {...props} type='drag'/>);
const input = container.querySelector('input')!;
const files = [
{
name: 'success.jpg',
Expand All @@ -266,7 +268,7 @@ describe('uploader', () => {
});

it('drag files with multiple false', done => {
const { container } = render(<Upload {...props} multiple={false} />);
const { container } = render(<Upload {...props} multiple={false} type='drag'/>);
const input = container.querySelector('input')!;
const files = [
new File([''], 'success.png', { type: 'image/png' }),
Expand Down Expand Up @@ -400,7 +402,8 @@ describe('uploader', () => {
});

it('dragging and dropping a non file with a file does not prevent the file from being uploaded', done => {
const input = uploader.container.querySelector('input')!;
const { container } = render(<Upload {...props} type='drag' />);
const input = container.querySelector('input')!;
const file = {
name: 'success.png',
};
Expand Down