Skip to content

fix(Upload): remove not work#4232

Open
RylanBot wants to merge 1 commit intodevelopfrom
rylan/fix/upload/remove
Open

fix(Upload): remove not work#4232
RylanBot wants to merge 1 commit intodevelopfrom
rylan/fix/upload/remove

Conversation

@RylanBot
Copy link
Copy Markdown
Collaborator

@RylanBot RylanBot commented May 9, 2026

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

复现代码
import React, { useState } from 'react';
import { Button, MessagePlugin, Space, Upload } from 'tdesign-react';

import type { UploadProps } from 'tdesign-react';

export default function UploadExample() {
  const [files, setFiles] = useState([]);

  const handleFail: UploadProps['onFail'] = ({ file }) => {
    MessagePlugin.error(`文件 ${file.name} 上传失败`);
  };

  const handleReset = () => {
    setFiles([]);
    MessagePlugin.info('已点击重置:setFiles([])');
  };
  const handleSubmit = () => {
    console.log('提交时的 files:', files);
    MessagePlugin.success('已点击提交,请查看控制台 files4');
  };

  return (
    <Space direction="vertical">
      <div style={{ border: '1px dashed #d9d9d9', padding: 16, borderRadius: 4 }}>
        <p style={{ marginBottom: 12, color: '#e34d59' }}>
          复现场景:选择任意文件触发上传失败 → 点击 「重置」按钮 → 失败文件无法被清除
        </p>
        <Upload
          theme="file-flow"
          files={files}
          onChange={setFiles}
          multiple
          autoUpload
          // 使个一定会上传失败的接口地址来复现失败状态
          action="https://service-bv448zsw-1257786608.gz.apigw.tencentcs.com/api/not-exist-will-fail"
          placeholder="支持任意文件,最多 10 个"
          max={10}
          formatResponse={(res) => ({ ...res, error: '上传失败,请重试' })}
          onFail={handleFail}
        />
        <Space style={{ marginTop: 12, justifyContent: 'flex-end', width: '100%' }}>
          <Button theme="default" onClick={handleReset}>
            重置
          </Button>
          <Button theme="primary" onClick={handleSubmit}>
            提交
          </Button>
        </Space>
      </div>
    </Space>
  );
}

💡 需求背景和解决方案

  • 初始文件 [],失败后也是 [],无法触发 UI 变化

(感觉有些设计有些缺陷...UI 显示了失败文件,但数据没变)

  • autoUpload 模式下,所有状态都在 uploadValue 里,符合直觉的
  • autoUpload 模式,把非成功文件分流到了内部 state (?)

📝 更新日志

  • 本条 PR 不需要纳入 Changelog

tdesign-react

@tdesign-react/chat

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@tdesign-bot
Copy link
Copy Markdown
Collaborator

TDesign Component Site Preview Open

Component Preview
tdesign-react 完成
@tdesign-react/chat 完成

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 9, 2026

  • tdesign-react-demo

    npm i https://pkg.pr.new/Tencent/tdesign-react@4232
    
    npm i https://pkg.pr.new/Tencent/tdesign-react/@tdesign-react/chat@4232
    

commit: 3348c35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants