Skip to content

Commit

Permalink
fix: Fix btn logic for antd4 (#525)
Browse files Browse the repository at this point in the history
* fix: fix: button trigger upload twice

* chore: remove

* chore: less diff
  • Loading branch information
yoyo837 authored Dec 22, 2023
1 parent 6e24053 commit d43e9cc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/AjaxUploader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* 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 classNames from 'classnames';
import pickAttrs from 'rc-util/lib/pickAttrs';
Expand Down Expand Up @@ -46,11 +44,14 @@ class AjaxUploader extends Component<UploadProps> {
if (!el) {
return;
}
const { children, onClick } = this.props;
if (children && (children as ReactElement).type === 'button') {

const target = e.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) {
Expand Down

0 comments on commit d43e9cc

Please sign in to comment.