fix(Upload): remove not work#4232
Open
RylanBot wants to merge 3 commits into
Open
Conversation
Collaborator
TDesign Component Site Preview Open
|
commit: |
RylanBot
commented
May 19, 2026
| setToUploadFiles([]); | ||
| xhrReq.current = []; | ||
| } else if (!props.autoUpload) { | ||
| uploadValue.splice(p.index, 1); |
Collaborator
Author
There was a problem hiding this comment.
复现代码 2 与日志 2 相关
FormItem.updateFormValue 的 isEqual 守卫,splice 污染原数组,误判为没有变化
场景对比
import React, { useState } from 'react';
import { Form, Space, Upload } from 'tdesign-react';
import type { RequestMethodResponse, UploadFile } from 'tdesign-react';
const { FormItem } = Form;
export default function UploadInFormDemo() {
const [form] = Form.useForm();
const mockUpload = (): Promise<RequestMethodResponse> =>
new Promise((resolve) => {
setTimeout(() => {
resolve({ status: 'success', response: { url: 'https://tdesign.gtimg.com/site/avatar.jpg' } });
}, 500);
});
return (
<Space direction="vertical" size={24}>
<div>
<p>Form 下【Bug】</p>
<Form form={form} labelWidth={100}>
<FormItem name="values">
<Upload
style={{ width: '100%' }}
theme="file-flow"
requestMethod={mockUpload}
draggable
multiple
autoUpload
/>
</FormItem>
</Form>
</div>
<div>
<p>不在 Form 下 / 非受控模式</p>
<Upload style={{ width: '100%' }} theme="file-flow" requestMethod={mockUpload} draggable multiple autoUpload />
</div>
<div style={{ marginTop: 24 }}>
<p>不在 Form 下 / 受控模式</p>
<ControlledUpload mockUpload={mockUpload} />
</div>
</Space>
);
}
function ControlledUpload({ mockUpload }: { mockUpload: () => Promise<RequestMethodResponse> }) {
const [files, setFiles] = useState<UploadFile[]>([]);
return (
<Upload
style={{ width: '100%' }}
theme="file-flow"
requestMethod={mockUpload}
draggable
multiple
autoUpload
files={files}
onChange={setFiles}
/>
);
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🤔 这个 PR 的性质是?
🔗 相关 Issue
复现代码1
复现代码2
💡 需求背景和解决方案
【日志 1 相关】
[],失败后也是[],无法触发 UI 变化(感觉有些设计有些缺陷...UI 显示了失败文件,但数据没变)
autoUpload模式下,所有状态都在 uploadValue 里,符合直觉的autoUpload模式,把非成功文件分流到了内部 state (?)📝 更新日志
tdesign-react
@tdesign-react/chat
☑️ 请求合并前的自查清单