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

feat: support name prop drilling #576

Merged
merged 3 commits into from
Aug 30, 2024
Merged
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
6 changes: 6 additions & 0 deletions src/AjaxUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ class AjaxUploader extends Component<UploadProps> {
classNames = {},
disabled,
id,
name,
style,
styles = {},
multiple,
Expand Down Expand Up @@ -307,6 +308,11 @@ class AjaxUploader extends Component<UploadProps> {
<input
{...pickAttrs(otherProps, { aria: true, data: true })}
id={id}
/**
* https://github.com/ant-design/ant-design/issues/50643,
* https://github.com/react-component/upload/pull/575#issuecomment-2320646552
*/
name={name}
disabled={disabled}
type="file"
ref={this.saveFileInput}
Expand Down
6 changes: 6 additions & 0 deletions tests/uploader.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ describe('uploader', () => {
expect(container.querySelector('input')!.id).toBe('bamboo');
});

// https://github.com/ant-design/ant-design/issues/50643
it('with name', () => {
const { container } = render(<Upload name="bamboo" />);
expect(container.querySelector('input')!.name).toBe('bamboo');
});

it('should pass through data & aria attributes', () => {
const { container } = render(
<Upload
Expand Down