picker icon indicating copy to clipboard operation
picker copied to clipboard

Fix:RangePicker the triangle sign was not positioned correctly in some cases

Open bbb169 opened this issue 1 year ago • 2 comments

fix: https://github.com/ant-design/ant-design/issues/51071

https://github.com/react-component/picker/blob/281bf3799b70838296b553632d885fc3b38ce1ca/src/PickerInput/Popup/index.tsx#L217 主要是这处的问题,trrigger自己改了popupAligin为tr,但是外面没有收到,依旧是以tl来判断offsetUnit,所以只要在popup重新调整placement的时候更新就行

Summary by CodeRabbit

  • 新功能

    • 引入了新的弹出框对齐属性,增强了弹出框的定位和对齐功能。
    • 添加了对弹出框位置变化的动态响应能力。
  • 测试

    • 新增了针对 DayRangePicker 组件弹出框箭头定位的测试用例,确保视觉对齐的准确性。

bbb169 avatar Oct 26 '24 14:10 bbb169

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 Nov 7, 2024 4:45pm

vercel[bot] avatar Oct 26 '24 14:10 vercel[bot]

[!CAUTION]

Review failed

The head commit changed during the review from 8f0cdc43c528c38e0c9cc21f77cdfb465ce72ab0 to f6ee13042967bfca88c3ee9bfbbbc83c709a9657.

Walkthrough

此次更改涉及多个组件的更新,主要是为了增强弹出窗口的对齐功能。PopupRangePickerRangeSelectorPickerTrigger 组件都引入了新的 alignedPlacement 属性,以改善弹出窗口的定位。此外,PickerContext 也进行了相应的更新,以支持新的状态管理。测试文件也进行了相应的修改,以确保新功能的正确性和稳定性。

Changes

文件路径 更改摘要
src/PickerInput/Popup/index.tsx 添加 alignedPlacement 属性,更新 realPlacement 变量,定义 onResize 函数以适应大小变化。
src/PickerInput/RangePicker.tsx 添加 alignedPlacement 状态,更新上下文依赖,修改 triggerOpen 函数以检查 disabled 状态。
src/PickerInput/Selector/RangeSelector.tsx 更新上下文以包含 alignedPlacement,优化 activeOffset 计算,调整 syncActiveOffset 的调用。
src/PickerInput/context.tsx PickerContextProps 接口中添加 alignedPlacementsetAlignedPlacement 属性。
src/PickerTrigger/index.tsx 更新 PickerTriggerProps 类型以包含 alignedPlacement,调整 realPlacement 逻辑。
tests/new-range.spec.tsx 扩展测试设置,增加新测试用例以验证弹出窗口箭头的正确定位。

Assessment against linked issues

Objective Addressed Explanation
确保 RangePicker 的三角标记在正确位置 (#51071)

Possibly related PRs

  • #873: 此 PR 涉及将 dropdownAlign 属性重命名为 popupAlign,与本 PR 引入的 alignedPlacement 属性相关。
  • #884: 此 PR 在多个组件中引入了 prefix 属性,与本 PR 中讨论的选择器组件的整体更新相关。

Suggested reviewers

  • zombieJ
  • afc163

Poem

在草地上跳跃的小兔,
新功能如花般盛开,
弹出窗口不再迷路,
对齐位置真是精彩!
让我们欢呼,尽情欢笑,
兔子们一起庆祝这变化! 🐇✨


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 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.

coderabbitai[bot] avatar Oct 26 '24 14:10 coderabbitai[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.46%. Comparing base (e1d6848) to head (f6ee130). Report is 17 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #886      +/-   ##
==========================================
+ Coverage   95.43%   95.46%   +0.02%     
==========================================
  Files          64       64              
  Lines        2719     2735      +16     
  Branches      762      773      +11     
==========================================
+ Hits         2595     2611      +16     
  Misses        121      121              
  Partials        3        3              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 28 '24 01:10 codecov[bot]

动画 @bbb169 好像还有点问题,点击右边的第一下不能正确指向,然后就是下面的activeBar位置不对

three-water666 avatar Oct 31 '24 05:10 three-water666

动画 动画 @bbb169 好像还有点问题,点击右边的第一下不能正确指向,然后就是下面的activeBar位置不对

是的 我再看看

bbb169 avatar Oct 31 '24 16:10 bbb169

动画 动画 @bbb169 好像还有点问题,点击右边的第一下不能正确指向,然后就是下面的activeBar位置不对

已修复

bbb169 avatar Nov 01 '24 13:11 bbb169

还有一个问题,这个问题好像之前就有,上右对齐的时候,箭头不在下方 动画

three-water666 avatar Nov 02 '24 06:11 three-water666

还有一个问题,这个问题好像之前就有,上右对齐的时候,箭头不在下方 动画 动画

这个问题跟本次的问题是一个解决方式 ,加个alignedPlacement就能解决了 trigger不需要做改动 : https://github.com/react-component/picker/pull/886/commits/cba76c7f9cdda54116f3295601b8481d2b5d0b21

bbb169 avatar Nov 03 '24 04:11 bbb169

还有一个问题,这个问题好像之前就有,上右对齐的时候,箭头不在下方 动画 动画

这个地方还有一个已有的问题 ,这个activeBar的位置总是差1px对不齐输入框,原因有两个

  1. 计算偏移时采取的是offsetLeft,这是个整数,当输入框发生flex坍缩时宽度就变成小数点了,这时拿到的offsetLeft就十分不正确
  2. 当输入框focus时,整个picker会有1px的border,这1px应该被考虑进来: https://github.com/react-component/picker/pull/886/commits/05eeced6aff1e54e00cd20e3f37b3aa2efaff6bd

@zombieJ

bbb169 avatar Nov 03 '24 07:11 bbb169