react-dropzone
Advanced tools
Comparing version 4.3.0 to 5.0.0
@@ -239,6 +239,6 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
if (!multiple) { | ||
if (!multiple && acceptedFiles.length > 1) { | ||
// if not in multi mode add any extra accepted files to rejected. | ||
// This will allow end users to easily ignore a multi file drop in "single" mode. | ||
rejectedFiles.push.apply(rejectedFiles, _toConsumableArray(acceptedFiles.splice(1))); | ||
rejectedFiles.push.apply(rejectedFiles, _toConsumableArray(acceptedFiles.splice(0))); | ||
} | ||
@@ -245,0 +245,0 @@ |
@@ -126,3 +126,3 @@ { | ||
}, | ||
"version": "4.3.0" | ||
"version": "5.0.0" | ||
} |
@@ -199,6 +199,6 @@ /* eslint prefer-template: 0 */ | ||
if (!multiple) { | ||
if (!multiple && acceptedFiles.length > 1) { | ||
// if not in multi mode add any extra accepted files to rejected. | ||
// This will allow end users to easily ignore a multi file drop in "single" mode. | ||
rejectedFiles.push(...acceptedFiles.splice(1)) | ||
rejectedFiles.push(...acceptedFiles.splice(0)) | ||
} | ||
@@ -205,0 +205,0 @@ |
@@ -625,16 +625,10 @@ import React from 'react' | ||
it('should add valid files to rejected files on a multple drop when multiple false', async () => { | ||
it('should reject invalid file when multiple is false', async () => { | ||
const dropzone = mount(<Dropzone accept="image/*" onDrop={dropSpy} multiple={false} />) | ||
await dropzone.simulate('drop', { dataTransfer: { files: images } }) | ||
const rejected = dropSpy.firstCall.args[0] | ||
expect(rejected.length).toEqual(1) | ||
}) | ||
it('should add invalid files to rejected when multiple is false', async () => { | ||
const dropzone = mount(<Dropzone accept="image/*" onDrop={dropSpy} multiple={false} />) | ||
await dropzone.simulate('drop', { | ||
dataTransfer: { files: images.concat(files) } | ||
dataTransfer: { files } | ||
}) | ||
const rejected = dropSpy.firstCall.args[1] | ||
expect(rejected.length).toEqual(2) | ||
const [accepted, rejected] = dropSpy.firstCall.args | ||
expect(rejected.length).toEqual(1) | ||
expect(accepted.length).toEqual(0) | ||
}) | ||
@@ -651,2 +645,11 @@ | ||
it('should reject multiple files to be dropped if multiple is false', async () => { | ||
const dropzone = mount(<Dropzone accept="image/*" onDrop={dropSpy} multiple={false} />) | ||
await dropzone.simulate('drop', { dataTransfer: { files: images } }) | ||
const [accepted, rejected] = dropSpy.firstCall.args | ||
expect(accepted.length).toEqual(0) | ||
expect(rejected.length).toEqual(2) | ||
}) | ||
it('should take all dropped files if multiple is true', async () => { | ||
@@ -653,0 +656,0 @@ const dropzone = mount(<Dropzone onDrop={dropSpy} multiple />) |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
255166
2529