Skip to content

Commit

Permalink
feat: support name prop drilling (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wxh16144 authored Aug 30, 2024
1 parent 99cdc3e commit 6c330b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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

0 comments on commit 6c330b4

Please sign in to comment.