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: React 19 scroll sync #902

Merged
merged 1 commit into from
Jan 7, 2025
Merged

fix: React 19 scroll sync #902

merged 1 commit into from
Jan 7, 2025

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Jan 7, 2025

fix ant-design/ant-design#52254

从代码看,每次传入新的fn做一次调用是符合预期的。但是这里如果返回的 units 是相同的,那滚动的确没有什么意义。

Summary by CodeRabbit

  • 性能优化

    • 优化了时间选择器组件中的依赖数组,减少不必要的重新渲染。
  • 测试改进

    • 改进了日期范围选择器的测试用例,增加了对用户输入的健壮性测试。
    • 修正了测试代码的格式和可读性。

Copy link

vercel bot commented Jan 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
picker ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 8:52am

Copy link

coderabbitai bot commented Jan 7, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/PickerPanel/TimePanel/TimePanelBody/TimeColumn.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object. (/.eslintrc.js:2:21)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)

变更概览

变更总结

本次变更涉及两个文件:src/PickerPanel/TimePanel/TimePanelBody/TimeColumn.tsxtests/picker.spec.tsx。在 TimeColumn.tsx 中,修改了 useLayoutEffect 钩子的依赖数组,改为使用 units.join(',') 来触发效果。在测试文件中,调整了 DayRangePicker 组件的渲染格式,并添加了一个新的测试用例,以验证组件在处理年份输入时的行为。

变更

文件路径 变更摘要
src/.../TimeColumn.tsx 修改 useLayoutEffect 钩子的依赖数组,使用 units.join(',') 替代原始的 units
tests/picker.spec.tsx 调整渲染格式,添加新的测试用例验证年份输入

对链接问题的评估

目标 是否解决 说明
解决 TimePicker.RangePicker 中 disabledTime 的滚动异常 [#52254] 当前变更未直接针对滚动问题,需要进一步调查

序列图

sequenceDiagram
    participant User
    participant TimeColumn
    participant ScrollComponent
    
    User->>TimeColumn: 选择时间
    TimeColumn->>ScrollComponent: 更新滚动位置
    ScrollComponent-->>TimeColumn: 响应滚动事件
Loading

庆祝诗歌

🐰 代码跳跃,兔子欢跃
依赖数组,精妙变化
测试闪耀,质量提升
小兔子笑,代码如诗
变更飞舞,技术之美 🌈


📜 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 ad3a1f7 and 28f4b86.

📒 Files selected for processing (2)
  • src/PickerPanel/TimePanel/TimePanelBody/TimeColumn.tsx (1 hunks)
  • tests/picker.spec.tsx (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test / react component workflow
🔇 Additional comments (4)
src/PickerPanel/TimePanel/TimePanelBody/TimeColumn.tsx (1)

57-57: 优化了 useLayoutEffect 的依赖数组!

通过将 units 数组转换为字符串,可以避免数组引用变化但内容相同时触发不必要的副作用。这是一个很好的性能优化。

tests/picker.spec.tsx (3)

295-295: 测试用例补充完善!

新增了 DayRangePicker 组件在输入年份时的边界测试,这有助于提高组件的稳定性。


1060-1063: 测试设置优化!

在每个测试用例之前重置 triggered 状态,确保测试用例之间相互独立,这是一个很好的测试实践。


1083-1122: 优化了 disabledTime 相关的测试覆盖!

新增测试用例验证了当 disabledTime 返回相同值时不会重复触发滚动,这个测试用例很好地覆盖了性能优化的场景。


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

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.47%. Comparing base (ad3a1f7) to head (28f4b86).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #902   +/-   ##
=======================================
  Coverage   95.47%   95.47%           
=======================================
  Files          64       64           
  Lines        2738     2738           
  Branches      770      742   -28     
=======================================
  Hits         2614     2614           
  Misses        121      121           
  Partials        3        3           

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

@zombieJ zombieJ merged commit c484f99 into master Jan 7, 2025
12 checks passed
@zombieJ zombieJ deleted the fix-19 branch January 7, 2025 08:55
@coderabbitai coderabbitai bot mentioned this pull request Jan 8, 2025
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.

TimePicker.RangePicker disabledTime 在選擇時間後出現異常滾動行為
1 participant