-
-
Notifications
You must be signed in to change notification settings - Fork 237
refactor: Add checker to ensure next open #571
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
Conversation
Caution Review failedThe pull request is closed. Walkthrough此变更为 UniqueProvider 增加 isOpen 回调缓存与关闭门控逻辑;扩展 UniqueContext.show 的签名以接收 isOpen;在 Trigger 内部所有 show 调用点传入 isOpen;测试文件仅做少量注释与空行删除,无行为改变。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User as User
participant Trigger as Trigger 组件
participant UniqueCtx as UniqueContext
participant Provider as UniqueProvider
note over Trigger,Provider: 新增/变更的交互
User->>Trigger: 触发显示 (hover/click)
Trigger->>UniqueCtx: show(options, isOpen)
UniqueCtx->>Provider: show(options, isOpen)
Provider->>Provider: isOpenRef = isOpen<br/>(记录最新回调)
Provider-->>User: 渲染/更新弹层
User->>Trigger: 条件变化/触发隐藏
Trigger->>UniqueCtx: hide(delay)
UniqueCtx->>Provider: hide(delay)
Provider->>Provider: 检查 isOpenRef.current?.()
alt isOpen() 为 true
Provider-->>Trigger: 终止隐藏(保持打开)
else isOpen() 为 false
Provider-->>Trigger: 执行关闭
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @zombieJ, 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 refactors the unique popup management logic to introduce a more robust control mechanism. It ensures that a popup remains visible if multiple triggers are attempting to manage its state, preventing it from being prematurely hidden. This is achieved by passing a dynamic isOpen
checker function to the show
method, which the hide
method then consults before executing a close operation, thereby improving the reliability of popup state management.
Highlights
- Enhanced Popup Control: Implemented a new mechanism to prevent unique popups from being prematurely hidden by introducing an
isOpen
checker function. - Refactored Show/Hide Logic: The
show
function now accepts anisOpen
callback, which thehide
function utilizes to determine if the popup should truly close, ensuring it remains open if another trigger intends for it to be visible. - Context Interface Update: The
UniqueContextProps
interface has been updated to reflect the new signature of theshow
function, which now includes theisOpen
callback.
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
-
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. ↩
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #571 +/- ##
==========================================
- Coverage 95.86% 95.78% -0.09%
==========================================
Files 18 18
Lines 944 949 +5
Branches 267 277 +10
==========================================
+ Hits 905 909 +4
- Misses 39 40 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a refactoring to prevent a shared unique popup from closing incorrectly when focus moves between different triggers, particularly for controlled components that update in the same render cycle. This is accomplished by passing an isOpen
status function from each Trigger
to the UniqueProvider
. The provider's hide
method now checks this status to determine if another trigger intends to keep the popup open. The implementation is solid, correctly handles the potential race condition, and the changes are applied consistently. I have no suggestions for improvement.
Summary by CodeRabbit