Skip to content

Commit

Permalink
fix: button logic (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ authored Dec 21, 2023
1 parent 5bfa1a5 commit d7e334a
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;

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

Expand Down

1 comment on commit d7e334a

@vercel
Copy link

@vercel vercel bot commented on d7e334a Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.