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: use Rect for logic #906

Merged
merged 4 commits into from
Feb 9, 2025
Merged

fix: use Rect for logic #906

merged 4 commits into from
Feb 9, 2025

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Feb 8, 2025

fix ant-design/ant-design#51071
close #886

直接用 getBoundingClientRect 来做相对位置计算,以无视来自于 Placement 的各种偏移、翻转的干扰。过去 offset size 计算可以支持 scale 的场景,但是目前看对于多次翻转会过于复杂。目前也没有看到相关 issue,先不用关注缩放场景。

Summary by CodeRabbit

  • 样式

    • 新增面板排版样式,使组件面板统一以单行排列,提升整体视觉一致性。
  • 内部调整

    • 优化弹出层及范围选择功能的定位逻辑,提高布局的准确性和响应性。
  • 测试

    • 更新相关测试用例,确保在尺寸调整后界面布局能稳定呈现。

Copy link

vercel bot commented Feb 8, 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 9, 2025 5:53am

Copy link

coderabbitai bot commented Feb 8, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

该PR对Picker组件的布局和状态管理进行了调整。样式上增加了面板布局的CSS类,组件内部则将原有单一数值的activeOffset和placement替换为包含多个信息的activeInfo元组,进而改进了Popup、RangePicker和RangeSelector中三角形的位置计算。与此同时,移除了部分无用的工具函数,并在测试中引入了resize事件的模拟,以确保组件响应正确。

Changes

文件 (Files) 变更描述 (Change Summary)
assets/index.less 新增CSS类&-panels,设置display: flex;flex-wrap: nowrap;,调整面板排列方式。
src/PickerInput/{Popup/index.tsx, RangePicker.tsx, Selector/RangeSelector.tsx} 替换原有activeOffset和placement为activeInfo元组,更新状态管理及偏移量计算逻辑,同时调整相关回调接口。
src/utils/uiUtil.ts 移除多项工具函数和类型,包括处理可见性、滚动、键盘事件、日期格式化和DOM包含检查的函数。
tests/range.spec.tsx 新增triggerResize函数,利用rc-resize-observer模拟resize事件;更新测试预期,将面板容器的margin-left从100px调整至50px。

Sequence Diagram(s)

sequenceDiagram
    participant RP as RangePicker
    participant RS as RangeSelector
    participant PP as Popup
    participant UI as UI Renderer

    RP->>RS: 初始化 activeInfo([0, 0, 0])
    RS->>RS: 计算输入框边界信息
    RS->>RP: 调用 onActiveInfo传递新的[左偏移, 右偏移, 宽度]
    RP->>PP: 传递 activeInfo 属性
    PP->>PP: 计算 arrowOffset基于 activeInfo
    PP->>UI: 更新弹出框和三角形位置
Loading

Assessment against linked issues

Objective Addressed Explanation
修复 RangePicker 中三角标未正确对齐的问题 (#51071, #886)

Suggested reviewers

  • afc163

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.

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+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/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/RangePicker.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+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/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/Selector/RangeSelector.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+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/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)
  • 1 others

📜 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 8863871 and fc3d53a.

⛔ Files ignored due to path filters (1)
  • tests/__snapshots__/range.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (6)
  • assets/index.less (1 hunks)
  • src/PickerInput/Popup/index.tsx (4 hunks)
  • src/PickerInput/RangePicker.tsx (3 hunks)
  • src/PickerInput/Selector/RangeSelector.tsx (3 hunks)
  • src/utils/uiUtil.ts (0 hunks)
  • tests/range.spec.tsx (3 hunks)

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

Codecov Report

Attention: Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.67%. Comparing base (8863871) to head (fc3d53a).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/PickerInput/Popup/index.tsx 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #906      +/-   ##
==========================================
+ Coverage   95.47%   98.67%   +3.20%     
==========================================
  Files          64       64              
  Lines        2740     2648      -92     
  Branches      742      732      -10     
==========================================
- Hits         2616     2613       -3     
+ Misses        121       32      -89     
  Partials        3        3              

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

@zombieJ zombieJ marked this pull request as ready for review February 9, 2025 05:55
@zombieJ zombieJ merged commit 97741dd into master Feb 9, 2025
10 of 12 checks passed
@zombieJ zombieJ deleted the fix-arrow branch February 9, 2025 05:55
@coderabbitai coderabbitai bot mentioned this pull request Feb 11, 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.

RangePicker the triangle sign was not positioned correctly in some cases
1 participant