Skip to content

Commit

Permalink
fix(Upload): should support itemRender on card listType, close alibab…
Browse files Browse the repository at this point in the history
  • Loading branch information
FairyYang committed Jul 8, 2024
1 parent 4ab101e commit 9539bc8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions components/upload/__tests__/index-spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,24 @@ describe('Upload', () => {
cy.get('@onChangeSpy').should('have.been.calledOnce');
cy.get('@onRemoveSpy').should('have.been.calledOnce');
});

it('should support itemRender', () => {
cy.mount(
<Upload
listType="card"
defaultValue={defaultValue}
itemRender={(file, obj) => {
return (
<div className="upload-card-itemRender" onClick={() => obj.remove?.()}>
{file.name}
</div>
);
}}
/>
);
cy.get('.upload-card-itemRender').should('have.length', 1);
cy.get('.upload-card-itemRender').should('contain', 'IMG.png');
});
});

describe('[render] drag', () => {
Expand Down
3 changes: 3 additions & 0 deletions components/upload/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ class Upload extends Base<UploadProps, UploadState> {
fileNameRender,
actionRender,
previewOnFileName,
itemRender,
...others
} = this.props;

Expand Down Expand Up @@ -482,6 +483,7 @@ class Upload extends Base<UploadProps, UploadState> {
onSuccess={this.onSuccess}
onError={this.onError}
ref={this.saveUploaderRef}
itemRender={itemRender}
>
{children}
</Uploader>
Expand All @@ -501,6 +503,7 @@ class Upload extends Base<UploadProps, UploadState> {
extraRender={extraRender}
rtl={rtl}
previewOnFileName={previewOnFileName}
itemRender={itemRender}
/>
) : null}
</div>
Expand Down

0 comments on commit 9539bc8

Please sign in to comment.