Skip to content

fix: preserve numeric shift inset after popup shift#609

Open
Damon4 wants to merge 1 commit intoreact-component:masterfrom
Damon4:master
Open

fix: preserve numeric shift inset after popup shift#609
Damon4 wants to merge 1 commit intoreact-component:masterfrom
Damon4:master

Conversation

@Damon4
Copy link

@Damon4 Damon4 commented Mar 17, 2026

Summary by CodeRabbit

发布说明

  • Bug Fixes

    • 弹出层现在会自动保持在可见区域内,防止边界溢出
  • Tests

    • 增加测试覆盖以验证弹出层边界约束功能

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where numeric shift values, intended to act as insets from the viewport edges, were not consistently applied after a popup's position was adjusted. The changes introduce new calculations to ensure that if a popup shifts due to overflow, it still maintains the specified numeric shiftX and shiftY as minimum distances from the visible region's boundaries, thus preserving the intended visual spacing.

Highlights

  • Popup Positioning Logic: Implemented new logic within the useAlign hook to ensure that numeric shiftX and shiftY values are respected as viewport insets, preventing popups from moving beyond these boundaries when their position is adjusted due to overflow.
  • Test Coverage: Added a new builtinPlacement configuration and a dedicated test case to validate that numeric shiftX is correctly preserved as a viewport inset after a popup shift, ensuring the fix behaves as expected.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/hooks/useAlign.ts
    • Added logic to adjust popup offset to preserve numeric shiftX and shiftY as viewport insets.
  • tests/flipShift.test.tsx
    • Added a new builtinPlacement configuration topShiftInset with shiftX.
    • Added a test case to verify that numeric shiftX is maintained as a viewport inset after a popup shift.
Activity
  • No activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d061b2b9-a21e-44fb-8bc3-735a73ff3bdc

📥 Commits

Reviewing files that changed from the base of the PR and between 59b659d and d5ad9fd.

📒 Files selected for processing (2)
  • src/hooks/useAlign.ts
  • tests/flipShift.test.tsx

功能概览

该 PR 在弹窗位置计算后添加了边界夹紧逻辑,确保弹窗在应用水平和竖直偏移后保持在可见区域内。对弹窗位置进行了两次调整,第二次调整通过限制偏移来防止溢出。

变更

内聚组 / 文件 摘要
边界夹紧逻辑
src/hooks/useAlign.ts
添加水平和竖直边界夹紧机制,在计算下一个弹窗偏移后重新计算弹窗位置,确保弹窗不会超出可见区域边界。
测试用例
tests/flipShift.test.tsx
新增 topShiftInset 配置和对应的测试用例,验证数值型 shiftX 在移位后作为视口内边距被正确应用。

预估代码审查工作量

🎯 2 (Simple) | ⏱️ ~10 minutes

可能相关的 PR

建议审查人

  • afc163
  • zombieJ

🐰 位置被夹紧,妙妙妙,
弹窗乖乖待视口,
二次调整保安全,
测试覆盖齐全了!✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题清晰准确地总结了主要变更:修复在弹出框移位后保留数值shift内边距的问题,与代码变更内容完全匹配。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces new logic to useAlign.ts to handle numShiftX and numShiftY properties, which allows popups to maintain a specified inset from the visible region's boundaries when positioned. This prevents popups from being placed too close to or outside the viewport edges. Correspondingly, a new topShiftInset placement configuration and a test case were added to flipShift.test.tsx to validate that a popup is correctly shifted to maintain a 20px left inset when it would otherwise be positioned off-screen.

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