mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
🐛 Fix always uploading if upload button is hidden during
close #14779 caused by the previous fix in #14298 reverted and change another way to fix #14299
This commit is contained in:
parent
dbc2e9d180
commit
8fc3cb8d24
@ -316,11 +316,17 @@ class Upload extends React.Component<UploadProps, UploadState> {
|
||||
[`${prefixCls}-disabled`]: disabled,
|
||||
});
|
||||
|
||||
const uploadButton = children ? (
|
||||
<div className={uploadButtonCls}>
|
||||
// Remove id to avoid open by label when trigger is hidden
|
||||
// https://github.com/ant-design/ant-design/issues/14298
|
||||
if (!children) {
|
||||
delete rcUploadProps.id;
|
||||
}
|
||||
|
||||
const uploadButton = (
|
||||
<div className={uploadButtonCls} style={children ? undefined : { display: 'none' }}>
|
||||
<RcUpload {...rcUploadProps} ref={this.saveUpload} />
|
||||
</div>
|
||||
) : null;
|
||||
);
|
||||
|
||||
if (listType === 'picture-card') {
|
||||
return (
|
||||
|
@ -188,6 +188,19 @@ describe('Upload', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/14779
|
||||
it('should contain input file control if upload button is hidden', () => {
|
||||
const wrapper = mount(
|
||||
<Upload action="http://upload.com">
|
||||
<button type="button">upload</button>
|
||||
</Upload>,
|
||||
);
|
||||
|
||||
expect(wrapper.find('input[type="file"]').length).toBe(1);
|
||||
wrapper.setProps({ children: null });
|
||||
expect(wrapper.find('input[type="file"]').length).toBe(1);
|
||||
});
|
||||
|
||||
it('should be controlled by fileList', () => {
|
||||
const fileList = [
|
||||
{
|
||||
|
@ -76,6 +76,7 @@ export interface UploadProps {
|
||||
withCredentials?: boolean;
|
||||
openFileDialogOnClick?: boolean;
|
||||
locale?: UploadLocale;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface UploadState {
|
||||
|
Loading…
Reference in New Issue
Block a user