Skip to content

Commit

Permalink
fix: button logic
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Dec 21, 2023
1 parent 5bfa1a5 commit c25ac05
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/AjaxUploader.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
/* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */
import type { ReactElement } from 'react';
import React, { Component } from 'react';
import clsx from 'classnames';
import pickAttrs from 'rc-util/lib/pickAttrs';
import defaultRequest from './request';
import getUid from './uid';
import React, { Component } from 'react';
import attrAccept from './attr-accept';
import traverseFileTree from './traverseFileTree';
import type {
UploadProps,
BeforeUploadFileType,
RcFile,
UploadProgressEvent,
UploadProps,
UploadRequestError,
RcFile,
BeforeUploadFileType,
} from './interface';
import defaultRequest from './request';
import traverseFileTree from './traverseFileTree';
import getUid from './uid';

interface ParsedFileInfo {
origin: RcFile;
Expand Down Expand Up @@ -41,20 +40,23 @@ class AjaxUploader extends Component<UploadProps> {
this.reset();
};

onClick = (e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => {
onClick = (event: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => {
const el = this.fileInput;
if (!el) {
return;
}
const { children, onClick } = this.props;
if (children && (children as ReactElement).type === 'button') {

const target = event.target as HTMLElement;
const { onClick } = this.props;

Check warning on line 50 in src/AjaxUploader.tsx

View check run for this annotation

Codecov / codecov/patch

src/AjaxUploader.tsx#L49-L50

Added lines #L49 - L50 were not covered by tests

if (target && target.tagName === 'BUTTON') {
const parent = el.parentNode as HTMLInputElement;
parent.focus();
parent.querySelector('button').blur();
target.blur();

Check warning on line 55 in src/AjaxUploader.tsx

View check run for this annotation

Codecov / codecov/patch

src/AjaxUploader.tsx#L55

Added line #L55 was not covered by tests
}
el.click();
if (onClick) {
onClick(e);
onClick(event);

Check warning on line 59 in src/AjaxUploader.tsx

View check run for this annotation

Codecov / codecov/patch

src/AjaxUploader.tsx#L59

Added line #L59 was not covered by tests
}
};

Expand Down

0 comments on commit c25ac05

Please sign in to comment.