Skip to content
Open
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
9 changes: 7 additions & 2 deletions src/AjaxUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,15 @@ class AjaxUploader extends Component<UploadProps> {
onMouseLeave,
onDrop: this.onFileDrop,
onDragOver: this.onFileDragOver,
tabIndex: hasControlInside ? undefined : '0',
tabIndex: hasControlInside || !openFileDialogOnClick ? undefined : '0',
};
return (
<Tag {...events} className={cls} role={hasControlInside ? undefined : 'button'} style={style}>
<Tag
{...events}
className={cls}
role={hasControlInside || !openFileDialogOnClick ? undefined : 'button'}
style={style}
>
<input
{...pickAttrs(otherProps, { aria: true, data: true })}
id={id}
Expand Down
7 changes: 7 additions & 0 deletions tests/uploader.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,13 @@ describe('uploader', () => {
expect(container.querySelector('span')!).not.toHaveAttribute('role', 'button');
});

it("Should not be focusable and doesn't have role=button when click upload is disabled", () => {
const { container } = render(<Upload openFileDialogOnClick={false} />);

expect(container.querySelector('span')!.tabIndex).not.toBe(0);
expect(container.querySelector('span')!).not.toHaveAttribute('role', 'button');
});

it('should receive same defaultRequest as src', done => {
const { default: srcRequest } = require('../src/request');
let receivedDefaultRequest: any;
Expand Down