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: Attachments FileList scroll button is not shown #556

Merged
merged 2 commits into from
Feb 25, 2025

Conversation

onefeng123
Copy link
Contributor

@onefeng123 onefeng123 commented Feb 25, 2025

问题描述

添加文件后,滚动按钮没有正确地显示出来
image

Summary by CodeRabbit

  • Bug Fixes
    • 优化了附件列表的更新响应逻辑,使界面能在文件项变更时更及时地刷新显示,从而提升整体用户体验。

Copy link
Contributor

coderabbitai bot commented Feb 25, 2025

📝 Walkthrough

"""

Walkthrough

本次变更修改了 FileList 组件中的 useEffect 钩子依赖数组,在原有仅依赖 overflow 的基础上增加了 items.length。这样,组件在 overflowitems 数组长度发生变化时均会调用 checkPing 函数,确保状态更新能够及时响应列表项的变化。

Changes

文件 变更摘要
components/.../FileList/index.tsx 修改 useEffect 依赖数组,增加 items.length,使得 checkPingoverflowitems.length 变化时触发

Sequence Diagram(s)

sequenceDiagram
    participant FileList as FileList组件
    participant useEffect as useEffect钩子
    participant checkPing as checkPing函数
    FileList->>useEffect: 检测到 overflow 或 items.length 变化
    useEffect->>checkPing: 执行 checkPing()
Loading

Possibly related PRs

Suggested reviewers

  • YumoImer

Poem

我是快乐的小兔子,跳跃在代码间,
依赖变动显风范,items与overflow共舞翩跹,
checkPing轻声呼唤,唤醒组件的每一次更新,
程序花园里乐无边,代码阳光洒满天! 🐰
前行开发步步高,梦中兔子庆丰年!
"""


📜 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 34f469d and 1fdaf3c.

📒 Files selected for processing (1)
  • components/attachments/FileList/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/attachments/FileList/index.tsx

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 Feb 25, 2025

Preview is ready

Copy link

Walkthrough

This pull request addresses an issue where the scroll button in the Attachments FileList was not displayed correctly after adding files. The fix involves modifying the dependency array of a useEffect hook to include items, ensuring the effect runs when items change.

Changes

File Summary
components/attachments/FileList/index.tsx Updated the dependency array of useEffect to include items to ensure the scroll button is displayed correctly when files are added.

@@ -77,7 +77,7 @@ export default function FileList(props: FileListProps) {

React.useEffect(() => {
checkPing();
}, [overflow]);
}, [overflow, items]);

Choose a reason for hiding this comment

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

The dependency array for useEffect has been updated to include items. This change ensures that the effect re-runs when items change, which is crucial for correctly displaying the scroll button when files are added.

… the entire items array

Co-authored-by: afc163 <afc163@gmail.com>
Copy link

codecov bot commented Feb 25, 2025

Bundle Report

Bundle size has no change ✅

@afc163 afc163 merged commit 65cda1b into ant-design:main Feb 25, 2025
9 checks passed
Copy link

codecov bot commented Feb 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.79%. Comparing base (7085686) to head (1fdaf3c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #556   +/-   ##
=======================================
  Coverage   91.79%   91.79%           
=======================================
  Files          67       67           
  Lines        1463     1463           
  Branches      371      371           
=======================================
  Hits         1343     1343           
  Misses        120      120           

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

@onefeng123 onefeng123 deleted the patch-1 branch February 26, 2025 02:45
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