diff --git a/components/upload/Upload.tsx b/components/upload/Upload.tsx index 07c1d8d897..8d9914f258 100644 --- a/components/upload/Upload.tsx +++ b/components/upload/Upload.tsx @@ -376,6 +376,10 @@ const InternalUpload: React.ForwardRefRenderFunction = ( downloadIcon, } = typeof showUploadList === 'boolean' ? ({} as ShowUploadListInterface) : showUploadList; + // use showRemoveIcon if it is specified explicitly + const realShowRemoveIcon = + typeof showRemoveIcon === 'undefined' ? !mergedDisabled : !!showRemoveIcon; + const renderUploadList = (button?: React.ReactNode, buttonVisible?: boolean) => { if (!showUploadList) { return button; @@ -389,7 +393,7 @@ const InternalUpload: React.ForwardRefRenderFunction = ( onPreview={onPreview} onDownload={onDownload} onRemove={handleRemove} - showRemoveIcon={!mergedDisabled && showRemoveIcon} + showRemoveIcon={realShowRemoveIcon} showPreviewIcon={showPreviewIcon} showDownloadIcon={showDownloadIcon} removeIcon={removeIcon} diff --git a/components/upload/__tests__/uploadlist.test.tsx b/components/upload/__tests__/uploadlist.test.tsx index 95c3f219b7..d7cb156775 100644 --- a/components/upload/__tests__/uploadlist.test.tsx +++ b/components/upload/__tests__/uploadlist.test.tsx @@ -579,6 +579,34 @@ describe('Upload List', () => { unmount(); }); + // https://github.com/ant-design/ant-design/issues/27519 + // https://github.com/ant-design/ant-design/issues/45735 + it('should show remove icon when showRemoveIcon is true', () => { + const list = [ + { + name: 'image', + status: 'uploading', + uid: '-4', + url: 'https://cdn.xxx.com/aaa', + }, + ]; + + const { container: wrapper, unmount } = render( + + + , + ); + expect(wrapper.querySelector('.anticon-delete')).toBeTruthy(); + unmount(); + }); + it('should support custom onClick in custom icon', async () => { const handleRemove = jest.fn(); const handleChange = jest.fn();