Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Upload): support itemRender on card listType, close #4721 #4882

Closed
wants to merge 1 commit into from
Closed
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
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 @@
fileNameRender,
actionRender,
previewOnFileName,
itemRender,
...others
} = this.props;

Expand Down Expand Up @@ -482,6 +483,7 @@
onSuccess={this.onSuccess}
onError={this.onError}
ref={this.saveUploaderRef}
itemRender={itemRender}

Check failure on line 486 in components/upload/upload.tsx

View workflow job for this annotation

GitHub Actions / changed

No overload matches this call.

Check failure on line 486 in components/upload/upload.tsx

View workflow job for this annotation

GitHub Actions / changed

No overload matches this call.
>
{children}
</Uploader>
Expand All @@ -501,6 +503,7 @@
extraRender={extraRender}
rtl={rtl}
previewOnFileName={previewOnFileName}
itemRender={itemRender}
/>
) : null}
</div>
Expand Down
Loading