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: 拖拽文件上传无法删除 #460

Merged
merged 7 commits into from
Jan 10, 2025

Conversation

Rain120
Copy link
Contributor

@Rain120 Rain120 commented Jan 9, 2025

问题来源

Sender 输入框的黏贴图片示例, 当直接向输入框拖拽图片等附件时, 资源无法被删除 #431

修复问题

问题定位

image

修复后

image

Summary by CodeRabbit

  • 样式调整
    • 修改了文件卡片组件的样式生成规则
    • 取消了溢出内容隐藏和移除图标的默认显示设置
    • 允许在不同条件下显示移除图标
    • 调整了文件卡片的视觉呈现方式

Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

📝 Walkthrough

变更概述

步骤概览

components/attachments/style/fileCard.ts 文件中,genFileCardStyle 函数的样式生成逻辑发生了变化。具体而言,overflow: 'hidden'&-motion 样式块中移除,取消了对动画元素溢出的限制。同时,强制设置 remove 图标为 display: 'none !important' 的样式块被完全删除。这些更改影响了文件卡片组件的布局和可见性控制流。

变更

文件路径 变更摘要
components/attachments/style/fileCard.ts 移除 overflow: 'hidden'display: 'none !important' 样式规则

可能相关的 PR

建议的审阅者

  • YumoImer

诗歌庆祝

🐰 代码兔子轻轻跳,
样式注释悄悄藏,
隐藏的行不再遮挡,
布局自由展翅膀!
代码改变,兔子欢笑 🎉


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 87f20a5 and a0939b4.

📒 Files selected for processing (1)
  • components/attachments/style/fileCard.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • components/attachments/style/fileCard.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build preview
  • GitHub Check: test / react component workflow
  • GitHub Check: size

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Jan 9, 2025

Preview is ready

Copy link

Walkthrough

修复了在输入框中拖拽文件上传后无法删除的问题。通过修改样式文件,解决了附件在拖拽上传后无法删除的bug。

Changes

文件 描述
components/attachments/style/fileCard.ts 修改了样式文件,注释掉了 overflow: 'hidden'display: 'none !important',以解决附件无法删除的问题。

@@ -162,13 +162,13 @@ const genFileCardStyle: GenerateStyle<AttachmentsToken> = (token) => {

// ============================== Motion ===============================
'&-motion': {
overflow: 'hidden',
// overflow: 'hidden',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释掉 overflow: 'hidden' 可能会影响其他样式的表现,确保这不会引入新的问题。

transition: ['opacity', 'width', 'margin', 'padding']
.map((prop) => `${prop} ${token.motionDurationSlow}`)
.join(','),

[`${cardCls}-remove`]: {
display: 'none !important',
// display: 'none !important',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释掉 display: 'none !important' 可能会影响元素的可见性,确保这不会引入新的问题。

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
components/attachments/style/fileCard.ts (1)

165-165: 修复拖拽上传文件删除按钮的可见性问题

这些更改通过移除强制隐藏样式,使删除按钮在拖拽上传后可以正常显示和使用。

  • 注释掉 overflow: 'hidden' 确保在动画过程中内容不会被截断
  • 注释掉 display: 'none !important' 允许删除按钮在需要时显示

建议添加注释说明这些更改的原因:

- // overflow: 'hidden',
+ // overflow: 'hidden', // 允许删除按钮在动画期间保持可见
- // display: 'none !important',
+ // display: 'none !important', // 修复 #431:允许拖拽上传文件的删除按钮显示

Also applies to: 171-171

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3fd663 and 87f20a5.

📒 Files selected for processing (1)
  • components/attachments/style/fileCard.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build preview
  • GitHub Check: test / react component workflow
  • GitHub Check: size
🔇 Additional comments (1)
components/attachments/style/fileCard.ts (1)

165-171: 验证样式更改的影响

请确认以下几点:

  1. 删除按钮在所有状态下(悬停、拖拽等)都能正常显示
  2. 动画过渡效果是否仍然平滑
  3. 在不同浏览器中测试这些更改的兼容性

运行以下命令检查是否有其他组件依赖这些样式:

✅ Verification successful

样式更改验证完成

经过验证,这些样式更改是安全的:

  1. 移除的样式仅出现在测试快照中,不会影响其他组件
  2. 新增的过渡动画与组件库中其他类似实现保持一致
  3. 删除 overflow: hiddendisplay: none !important 有助于改善动画效果

请记得更新相关的测试快照。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 搜索可能受影响的相关样式
rg -l "overflow:\s*hidden" "components/"
rg -l "display:\s*none\s*!important" "components/"

Length of output: 229


Script:

#!/bin/bash
# 搜索相关的过渡动画样式和类名
rg -A 5 "transition.*motionDurationSlow" "components/"

# 搜索相关的类名使用
rg "cardCls-remove" "components/"

# 检查测试快照中的相关样式
cat "components/attachments/__tests__/__snapshots__/demo.test.tsx.snap"
cat "components/attachments/__tests__/__snapshots__/demo-extend.test.ts.snap"

Length of output: 66947

Copy link

codecov bot commented Jan 9, 2025

Bundle Report

Bundle size has no change ✅

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.45%. Comparing base (4076798) to head (a0939b4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #460   +/-   ##
=======================================
  Coverage   91.45%   91.45%           
=======================================
  Files          67       67           
  Lines        1462     1462           
  Branches      385      384    -1     
=======================================
  Hits         1337     1337           
  Misses        125      125           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@YumoImer
Copy link
Collaborator

注释的代码直接删了吧~其他没问题了

Copy link
Collaborator

@YumoImer YumoImer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢贡献!

@YumoImer YumoImer merged commit dadb26d into ant-design:main Jan 10, 2025
11 checks passed
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.

Sender 输入框的黏贴图片示例, 当直接向输入框拖拽图片等附件时, 资源无法被删除
2 participants