trigger icon indicating copy to clipboard operation
trigger copied to clipboard

fix: popup glitch when not enough width

Open jon-cullison opened this issue 10 months ago • 7 comments

This is a fix for #496 which was introduced in https://github.com/react-component/trigger/pull/419

That change moved setting the height/width to before the popupElement reset, which makes the calculations that use height/width incorrect. Moving the height/width assignment back to after the popupElement reset fixes the glitch caused by incorrect calculations.

Summary by CodeRabbit

  • Refactor
    • 优化了弹出窗口尺寸获取和对齐计算的内部逻辑,简化了代码结构。
    • 调整后的处理方案确保窗口显示与定位保持稳定,用户体验不受影响。

jon-cullison avatar Feb 14 '25 20:02 jon-cullison

Walkthrough

本次变更修改了 src/hooks/useAlign.ts 文件中的 useAlign 函数,将原先通过结构赋值从 popupElement 的 computed style 中获取 widthheight 的逻辑移除,改为使用其他方式获取这两个尺寸值。对齐计算及后续逻辑基本保持不变,但新方式的尺寸获取需要确保后续计算依然正确。

Changes

文件 变更说明
src/hooks/useAlign.ts 移除了直接结构赋值提取 widthheight 的代码,改用其他方式赋值尺寸,用于对齐计算

Possibly related PRs

  • react-component/trigger#481: 与当前 PR 类似,针对 useAlign 中尺寸获取和对齐逻辑进行了调整,存在代码层面的关联。

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/hooks/useAlign.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@[email protected][email protected]/node_modules/@umijs/fabric/dist/eslint.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

✨ Finishing Touches
  • [ ] 📝 Generate Docstrings (Beta)

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.

coderabbitai[bot] avatar Feb 14 '25 20:02 coderabbitai[bot]

Codecov Report

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

Project coverage is 97.75%. Comparing base (a9c5ec8) to head (78caaf9). Report is 17 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #510   +/-   ##
=======================================
  Coverage   97.75%   97.75%           
=======================================
  Files          13       13           
  Lines         800      801    +1     
  Branches      235      231    -4     
=======================================
+ Hits          782      783    +1     
  Misses         18       18           

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

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Feb 18 '25 02:02 codecov[bot]

@zombieJ @afc163 Can we get this PR merged please?

mellis481 avatar Feb 24 '25 14:02 mellis481

ping @zombieJ

afc163 avatar Feb 25 '25 02:02 afc163

@zombieJ @afc163 Could we please get this PR merged?

jon-cullison avatar Mar 03 '25 14:03 jon-cullison

@zombieJ @afc163 Could we please get this PR merged?

yhy-1 avatar Mar 21 '25 20:03 yhy-1

Please add some test case to cover it.

yoyo837 avatar Mar 27 '25 14:03 yoyo837

Please add some test case to cover it.

@yoyo837

I have tried to reproduce the issue in a test case, but it does not occur when testing using jest / react testing library. The popover is not being styled or positioned the same in jest as it is in a browser.

Please advise.

jon-cullison avatar Apr 15 '25 18:04 jon-cullison

@yoyo837 Can you please provide some direction/input based on @jon-cullison's last comment?

mellis481 avatar May 19 '25 17:05 mellis481

It doesn't look easy to mock by jest / react testing library.

yoyo837 avatar May 20 '25 01:05 yoyo837

+ @rc-component/[email protected]

for antd side, it will take effect in next branch

zombieJ avatar Jun 17 '25 08:06 zombieJ