Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(upload): fix the upload status not being updated if the upload was successful #2133

Merged
merged 7 commits into from Jun 28, 2023

Conversation

zhangzhonghe
Copy link
Contributor

@zhangzhonghe zhangzhonghe commented Jun 27, 2023

Description (Bug 描述)

Steps to reproduce (复现步骤)

  1. 批量上传多张图片
  2. 会发现样式问题

image

Expected behavior (预期行为)

  • 图片的名字不应该被下面的图片盖住
  • 图片上传成功后应该更新状态并显示已上传的图片

Actual behavior (实际行为)

  • 图片的名字被盖住
  • 某些图片上传成功了,但是依然显示 uploading

Related issues (相关 issue)

#1862
ant-design/ant-design#2423

Reason (原因)

  • refactor(association-field): support sub table #1862 修改了样式,导致图片名称被覆盖
  • 一直显示 uploading 的问题是因为 antd 的 BUG,导致 onChange 方法的 fileList 参数的值没有及时的更新,需要 antd 团队修复该问题
  • 这个功能之前是好的,现在出问题,怀疑可能跟最近的 React 升级到 18 版本有关(未验证)

Solution (解决方案)

  • 回退样式
  • 关于一直显示 uploading 的问题
    • 首先,使用官方推荐的方法不能解决这里遇到的问题
    • 经测试发现 onChangefile 参数是正确的,所以可以根据 file 实时的计算出 fileList 的值
    • 计算出的 fileList 需要通过一个 useRef 保存,如果使用 useState 同样会有问题
    • 在删除图片的时候,同时需要删除 Ref 中的值

修复后的样子

image

其它

close T-650

@height
Copy link

height bot commented Jun 27, 2023

This pull request has been linked to and will mark 1 task as "Done" when merged:

💡Tip: You can link multiple Height tasks to a pull request.

@zhangzhonghe zhangzhonghe changed the title fix(Upload): fix the upload status does not change fix(Upload): fix style Jun 27, 2023
@zhangzhonghe zhangzhonghe changed the title fix(Upload): fix style fix(Upload): fix the upload status not being updated if the upload was successful Jun 27, 2023
@chenos chenos changed the title fix(Upload): fix the upload status not being updated if the upload was successful fix(upload): fix the upload status not being updated if the upload was successful Jun 28, 2023
@chenos chenos merged commit d71fed0 into main Jun 28, 2023
4 checks passed
@chenos chenos deleted the T-650 branch June 28, 2023 07:38
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.

None yet

2 participants