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: 修复 Popover.Confirm 的弹出容器的宽度在Table中有可能显示较窄的问题 #736

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

saint3347
Copy link
Collaborator

@saint3347 saint3347 commented Oct 17, 2024

Types of changes

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Others

Changelog

  • 修复 Popover.Confirm 的弹出容器的宽度在Table中有可能显示较窄的问题

Summary by CodeRabbit

  • 新功能

    • 更新了版本号至 3.4.4-beta.8
    • 在变更日志中新增了关于 Popover.Confirm 组件的修复信息。
  • 错误修复

    • 修复了在表格上下文中 Popover.Confirm 弹出容器宽度过窄的问题。
    • 修复了在极端边界情况下 Popover 可见性的问题。
  • 测试

    • 更新了 Textarea 组件的测试,以反映新的信息和错误显示逻辑。

Copy link

coderabbitai bot commented Oct 17, 2024

Walkthrough

此次更改主要包括三个部分:package.json文件的版本号更新,从"3.4.4-beta.7"更改为"3.4.4-beta.8";对packages/hooks/src/utils/position.ts文件中getPopoverPosition函数的逻辑进行了修改,移除了与弹出框内容宽度相关的代码块;在packages/shineout/src/popover/__doc__/changelog.cn.md文件中新增了关于版本3.4.4-beta.8的变更日志,记录了与Popover.Confirm组件相关的一个bug修复。

Changes

文件路径 更改摘要
package.json 版本更新:"version": "3.4.4-beta.7""version": "3.4.4-beta.8"
packages/hooks/src/utils/position.ts 修改getPopoverPosition函数,移除与弹出框宽度相关的逻辑,简化了位置计算。
packages/shineout/src/popover/__doc__/changelog.cn.md 新增版本3.4.4-beta.8的变更日志,记录了与Popover.Confirm组件相关的bug修复。

Possibly related PRs

兔子欢快跳跃,
版本更新真美妙,
弹出框更灵动,
日志记录新变化,
让我们一起庆祝,
这次更改真是好! 🐇✨


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.

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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e2d8b02 and 50a9216.

📒 Files selected for processing (3)
  • package.json (1 hunks)
  • packages/hooks/src/utils/position.ts (1 hunks)
  • packages/shineout/src/popover/doc/changelog.cn.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • package.json
🧰 Additional context used
🔇 Additional comments (1)
packages/shineout/src/popover/__doc__/changelog.cn.md (1)

1-5: 更改日志条目格式正确,内容清晰。

新的更改日志条目格式正确,包含了所有必要的信息。bug 修复的描述简洁明了,PR 编号引用正确,日期格式也符合要求。

值得注意的是,此版本号为 beta 版本(3.4.4-beta.8)。如果这是有意为之,那么一切正常。但如果这不是预期的版本号,可能需要进行调整。

请运行以下脚本来验证版本号的一致性:

✅ Verification successful

版本号验证通过,package.json 中的版本号与更改日志中的版本号一致。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证 package.json 中的版本号是否与更改日志一致

# 测试:查找 package.json 中的版本号。预期:应与更改日志中的版本号匹配。
jq -r '.version' package.json

Length of output: 42

Comment on lines +78 to +94
// TODO: 暂时移除,另考虑方案
// 如果渲染了弹出内容,则根据弹出内容宽度计算是否自动调整位置
if (popupRect) {
if (popupRect?.width / 2 > rect.left) {
position += '-left';
}
if (popupRect?.width / 2 > windowWidth - rect.right) {
position += '-right';
}
} else {
// 兜底计算
if (horizontalPoint > windowWidth * 0.6) {
position += '-right';
} else if (horizontalPoint < windowWidth * 0.4) {
position += '-left';
}
// if (popupRect && popupRect?.width) {
// if (popupRect?.width / 2 > rect.left) {
// position += '-left';
// }
// if (popupRect?.width / 2 > windowWidth - rect.right) {
// position += '-right';
// }
// } else {
// 兜底计算
if (horizontalPoint > windowWidth * 0.6) {
position += '-right';
} else if (horizontalPoint < windowWidth * 0.4) {
position += '-left';
}
// }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

需要重新考虑弹出框定位逻辑

  1. 移除基于弹出内容宽度的定位逻辑可能会影响某些场景下弹出框的准确定位。特别是在弹出内容较宽的情况下,可能会导致显示不完整或位置不合理的问题。

  2. TODO 注释表明正在考虑替代方案。建议尽快确定新的解决方案,以确保弹出框在各种情况下都能正确定位。在实现新方案之前,可以考虑添加一个 FIXME 注释,以便跟踪这个待解决的问题。

  3. 当前的兜底计算逻辑相对简单,可能无法处理所有用例。建议增强fallback逻辑,考虑更多因素,如:

    • 弹出内容的预估宽度
    • 目标元素的大小和位置
    • 可用的屏幕空间

建议:

  1. 制定清晰的计划来解决这个定位问题,可能需要重新设计定位算法。
  2. 在实现新方案之前,可以添加日志或警告,以便在生产环境中监控可能出现的定位问题。
  3. 考虑添加配置选项,允许用户在需要时手动指定弹出框的首选位置。

您是否需要我协助设计新的定位算法或创建相关的GitHub issue来跟踪这个问题?

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

🧹 Outside diff range and nitpick comments (3)
packages/shineout/src/textarea/__test__/textarea.spec.tsx (3)

163-164: 添加了有用的注释解释

添加解释性注释是个好做法,它有助于其他开发者理解为什么使用 document.querySelector

建议:考虑将注释翻译成英文,以保持代码库的语言一致性,除非项目规范特别要求使用中文注释。

您是否需要我协助将注释翻译成英文?


168-169: 更新了错误状态的测试逻辑和注释

这个更改正确地反映了组件行为的变化。使用 document.querySelectorAll 确保了即使信息元素被渲染到其他位置,测试也能正确验证其不存在。

建议:

  1. 为保持一致性,考虑将所有注释翻译成英文。
  2. 可以稍微调整测试描述,使其更明确地表达现在是在整个文档范围内检查,而不仅仅是在容器内。

如果需要,我可以协助您改进这些注释和测试描述。


182-183: 更新了元素查询方法和选择器

这些更改正确反映了组件结构的变化:

  1. 第182-183行:使用 container.querySelectorAll 确保在容器内查找元素,与之前的更改保持一致。
  2. 第199-200行:新的选择器更具体地定位了错误消息元素,反映了可能的弹出框结构变化。

建议:为保持一致性,考虑在第199-200行也使用 container.querySelector 而不是隐式的 document.querySelector。这样可以确保测试的范围始终限定在组件的直接容器内。

如果您需要,我可以提供具体的代码修改建议。

Also applies to: 199-200

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 50a9216 and 87c3534.

📒 Files selected for processing (1)
  • packages/shineout/src/textarea/test/textarea.spec.tsx (4 hunks)
🧰 Additional context used
🔇 Additional comments (1)
packages/shineout/src/textarea/__test__/textarea.spec.tsx (1)

154-155: 更新了信息元素的查询方法

这个更改看起来是正确的。通过使用 document.querySelectorAll 而不是 container.querySelectorAll,测试现在能够检测到可能被渲染在组件直接容器之外的信息元素。这种变化表明组件的实现可能已经改变,将信息元素渲染到了更高的 DOM 层级。

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