diff --git a/components/carousel/index.tsx b/components/carousel/index.tsx index 0a69e12346..8547440efe 100644 --- a/components/carousel/index.tsx +++ b/components/carousel/index.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import isPlainObject from 'lodash/isPlainObject'; import debounce from 'lodash/debounce'; import SlickCarousel, { Settings } from '@ant-design/react-slick'; import classNames from 'classnames'; @@ -107,7 +106,7 @@ export default class Carousel extends React.Component { const dotPosition = this.getDotPosition(); props.vertical = dotPosition === 'left' || dotPosition === 'right'; - const enableDots = props.dots === true || isPlainObject(props.dots); + const enableDots = !!props.dots; const dsClass = classNames( dotsClass, `${dotsClass}-${dotPosition || 'bottom'}`, diff --git a/components/upload/Upload.tsx b/components/upload/Upload.tsx index 344e6fa7bf..1bbfe6ea3e 100644 --- a/components/upload/Upload.tsx +++ b/components/upload/Upload.tsx @@ -1,8 +1,6 @@ import * as React from 'react'; import RcUpload from 'rc-upload'; import classNames from 'classnames'; -import uniqBy from 'lodash/uniqBy'; -import findIndex from 'lodash/findIndex'; import Dragger from './Dragger'; import UploadList from './UploadList'; import { @@ -85,7 +83,7 @@ class Upload extends React.Component { const nextFileList = fileList.concat(); - const fileIndex = findIndex(nextFileList, ({ uid }: UploadFile) => uid === targetItem.uid); + const fileIndex = nextFileList.findIndex(({ uid }: UploadFile) => uid === targetItem.uid); if (fileIndex === -1) { nextFileList.push(targetItem); } else { @@ -209,12 +207,17 @@ class Upload extends React.Component { } const result = beforeUpload(file, fileList); if (result === false) { + // Get unique file list + const uniqueList: UploadFile[] = []; + stateFileList.concat(fileList.map(fileToObject)).forEach(f => { + if (uniqueList.every(uf => uf.uid !== f.uid)) { + uniqueList.push(f); + } + }); + this.onChange({ file, - fileList: uniqBy( - stateFileList.concat(fileList.map(fileToObject)), - (item: UploadFile) => item.uid, - ), + fileList: uniqueList, }); return false; } diff --git a/package.json b/package.json index 442e2e568f..b9176ee28b 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,7 @@ "rc-picker": "~1.4.0", "rc-progress": "~2.5.0", "rc-rate": "~2.5.1", - "rc-resize-observer": "^0.1.0", + "rc-resize-observer": "^0.2.0", "rc-select": "~10.1.0", "rc-slider": "~9.2.3", "rc-steps": "~3.5.0",