Skip to content
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
5 changes: 3 additions & 2 deletions src/AjaxUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ class AjaxUploader extends Component<UploadProps> {
const dirProps: any = directory
? { directory: 'directory', webkitdirectory: 'webkitdirectory' }
: {};
const isInteractive = openFileDialogOnClick && !hasControlInside;
const events = disabled
? {}
: {
Expand All @@ -382,10 +383,10 @@ class AjaxUploader extends Component<UploadProps> {
onMouseLeave,
onDrop: this.onFileDrop,
onDragOver: this.onFileDragOver,
tabIndex: hasControlInside ? undefined : '0',
tabIndex: isInteractive ? '0' : undefined,
};
return (
<Tag {...events} className={cls} role={hasControlInside ? undefined : 'button'} style={style}>
<Tag {...events} className={cls} role={isInteractive ? 'button' : undefined} 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 @@ -1399,6 +1399,13 @@ describe('uploader', () => {
expect(container.querySelector('span')!).not.toHaveAttribute('role', 'button');
});

it("Should not be focusable and doesn't have role=button with openFileDialogOnClick=false", () => {
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
Loading