Skip to content

fix: arrow position retry #909

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

Merged
merged 2 commits into from
Feb 17, 2025
Merged

fix: arrow position retry #909

merged 2 commits into from
Feb 17, 2025

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Feb 17, 2025

ref ant-design/ant-design#52851

Summary by CodeRabbit

  • 新功能
    • 优化了弹出组件在布局调整时的响应能力,提升了显示的稳定性和流畅性。
    • 增强了日期范围选择器的交互体验,在多种使用场景下保证选择操作的准确性与一致性。

Copy link

vercel bot commented Feb 17, 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 Feb 17, 2025 0:08am

Copy link

coderabbitai bot commented Feb 17, 2025

Walkthrough

该变更涉及两个主要部分。首先,在 PickerInputPopup 组件中新增了 retryTimes 状态变量,并修改了响应 activeInputLeft 改变和布局尺寸异常时的 effect 逻辑。其次,对 DayRangePicker 相关的测试文件进行了大幅更新,增加了多种场景的测试用例,包括禁用日期、鼠标事件、快照测试以及 shadow DOM 环境下的渲染验证。

Changes

文件 更改摘要
src/PickerInput/Popup/index.tsx 新增 retryTimes 状态变量,并在 effect 中依据布局尺寸异常递减该值。
tests/range.spec.tsx 更新和新增多个测试用例,覆盖禁用日期、鼠标事件、快照与 shadow DOM 渲染等场景。

Sequence Diagram(s)

sequenceDiagram
    participant Popup
    participant Effect
    Popup->>Effect: activeInputLeft 变化
    Effect->>Popup: 设置 retryTimes = 10
    alt wrapperRect 高度为 0 或右边界小于 0
        Effect-->>Popup: 递减 retryTimes
    else 尺寸有效
        Effect->>Popup: 保持当前 retryTimes 值
    end
Loading

Possibly related PRs

  • fix: fix jump panel #907: 此 PR 修改了 Popup 组件中的状态和 effect 逻辑,与本次新增的 retryTimes 控制逻辑有直接联系。
  • fix: use Rect for logic #906: 此 PR 针对 Popup 组件中有关布局和定位的逻辑进行了调整,与本次对尺寸异常处理的改进相关。

Poem

我是小兔在代码园中飞,
重试数字悄悄由零增十,
组件新逻辑智巧又灵动,
测试齐全护航如星辉,
代码世界兔跃新未来! 🐇💻

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.

tests/range.spec.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/PickerInput/Popup/index.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)

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

@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 (2)
src/PickerInput/Popup/index.tsx (2)

105-109: 在使用 state 管理重试次数时需考虑重复渲染的影响。
activeInputLeft 变化时,将 retryTimes 重置为 10,可能导致 effect 多次触发并造成不必要的重复渲染。可考虑在逻辑上增加额外条件或限制,避免性能压力。


141-141: retryTimes 添加到依赖列表可使布局重试不断进行,但也会增加渲染次数。
每次重试都会再次执行该 effect。虽然有上限,但请确保不会带来明显的性能开销或影响用户体验。

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 23ff742 and 79ec125.

⛔ Files ignored due to path filters (1)
  • tests/__snapshots__/range.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • src/PickerInput/Popup/index.tsx (3 hunks)
  • tests/range.spec.tsx (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: ✅ test
tests/range.spec.tsx

[error] 1917-1917: Snapshot test failed for 'Picker.Range use dateRender and monthCellRender in month range picker'.


[error] 1929-1929: Snapshot test failed for 'Picker.Range use dateRender and monthCellRender in date range picker'.

🔇 Additional comments (2)
tests/range.spec.tsx (1)

1835-1835: 在单元测试中强制设置 height=1 可能导致快照不一致。
此处会让模拟的组件高度固定为 1,可能与真实场景下的样式或布局不匹配,从而导致 snapshot 测试失败。建议确认是否需要更新测试快照或使用更具代表性的模拟值。

src/PickerInput/Popup/index.tsx (1)

120-124: 通过递减 retryTimes 进行布局重试的逻辑可行,但需避免无效循环。
在获取不到有效 wrapperRect 时递减重试次数并中断,会再次触发 effect。建议确认在实际场景中能满足预期需求,并避免一直无法获取有效矩形时的死循环或错误状态。

Copy link

codecov bot commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.71%. Comparing base (23ff742) to head (49778e3).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #909   +/-   ##
=======================================
  Coverage   98.71%   98.71%           
=======================================
  Files          64       64           
  Lines        2646     2652    +6     
  Branches      735      736    +1     
=======================================
+ Hits         2612     2618    +6     
  Misses         31       31           
  Partials        3        3           

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

@zombieJ zombieJ merged commit c012bfd into master Feb 17, 2025
12 checks passed
@zombieJ zombieJ deleted the fix-arrow branch February 17, 2025 12:09
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.

1 participant