Skip to content

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Sep 17, 2025

Summary by CodeRabbit

  • 新功能
  • Bug Fixes
    • 修复嵌套触发场景下的同步问题:在存在父级触发器时不再重复显示/隐藏,减少弹层闪烁与状态错乱;目标元素变更时可正确同步。
  • Refactor
    • 统一使用默认弹层容器,移除自定义容器设置,提升一致性且不影响对外 API。

Copy link

coderabbitai bot commented Sep 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

本次变更移除 UniqueProvider 中传递给 Popup 的 getPopupContainer 属性;在 Trigger 逻辑中为 UniqueProvider 同步与触发 open 的位置增加 parentContext 判定与注释,并在 effect 依赖中加入 targetEle,避免在存在父级上下文时与 UniqueProvider 交互。

Changes

Cohort / File(s) Summary of Changes
UniqueProvider Popup 属性调整
src/UniqueProvider/index.tsx
移除传递给 Popup 的 getPopupContainer 属性(改为注释掉),其余渲染逻辑保持不变。
Trigger 与 UniqueProvider 同步守护
src/index.tsx
useLayoutEffect 与非受控 triggerOpen 流程中加入 !parentContext 判定;为 effect 添加 targetEle 依赖;补充说明性注释,防止存在父级 Trigger 上下文时调用 uniqueContext.show/hide

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as 用户
  participant T as Trigger
  participant UC as UniqueContext
  participant UP as UniqueProvider/Popup

  U->>T: 交互(进入/离开、点击等)
  Note over T: 计算 open 状态(受控/非受控)

  alt 非受控且存在 UniqueContext
    alt 无父级上下文(!parentContext)
      T->>UC: show()/hide()
      UC->>UP: 同步可见性
      UP-->>U: 展示/隐藏弹层
    else 有父级上下文(parentContext)
      Note over T,UC: 抑制与 UniqueProvider 的交互
    end
  else 受控或无 UniqueContext
    Note over T: 仅内部处理或无同步
  end

  Note over T: useLayoutEffect 依赖包括 targetEle
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • MadCcc

Poem

小兔敲键跳三下,
父子上下各为家。
parentContext轻声说:别扰她,
Popup不再找容器啦。
逻辑分明云开花,
目标一变再出发。 🐇✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch nest-ignore

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 945cf85 and 6b27101.

📒 Files selected for processing (2)
  • src/UniqueProvider/index.tsx (1 hunks)
  • src/index.tsx (3 hunks)

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.

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.

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 refines the component's behavior in nested scenarios by explicitly preventing certain context-related operations when a parent context is present. The changes aim to avoid unintended interactions and simplify the management of popups and triggers within complex UI hierarchies, ensuring more predictable and stable component behavior.

Highlights

  • Nested Context Handling: Introduced a !parentContext check in useLayoutEffect and other trigger generation logic to prevent uniqueContext methods from being called when a parent context is detected, avoiding potential conflicts in nested component structures.
  • Prop Removal for Nested Scenarios: The getPopupContainer prop is now commented out and no longer passed to the FloatBg component within UniqueProvider, likely to simplify behavior and prevent issues in nested usage cases.
  • Effect Dependency Update: The useLayoutEffect hook's dependency array was updated to include targetEle, ensuring that the effect re-runs correctly when the target element changes, which is crucial for proper context synchronization.
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.

Copy link

codecov bot commented Sep 17, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.83%. Comparing base (945cf85) to head (6b27101).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/index.tsx 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #569      +/-   ##
==========================================
- Coverage   95.92%   95.83%   -0.09%     
==========================================
  Files          18       18              
  Lines         932      937       +5     
  Branches      259      264       +5     
==========================================
+ Hits          894      898       +4     
- Misses         38       39       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

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

This pull request aims to prevent nested Trigger components from using the unique feature by checking for a parentContext. The changes in src/index.tsx correctly implement this by adding !parentContext to the conditions for interacting with uniqueContext. Additionally, a dependency array for a useLayoutEffect is fixed, which is a good correction. My main feedback is regarding a commented-out line of code in src/UniqueProvider/index.tsx, which should be removed for better code quality.

motion={options.popupMotion}
maskMotion={options.maskMotion}
getPopupContainer={options.getPopupContainer}
// getPopupContainer={options.getPopupContainer}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This line is commented out. If the getPopupContainer prop is no longer intended to be supported by UniqueProvider, it's better to remove this line entirely rather than commenting it out. This practice helps to avoid dead code and makes the codebase cleaner and easier to maintain.

If this is an intentional removal of functionality, you might also consider removing getPopupContainer from the UniqueShowOptions interface in src/context.ts to maintain consistency across the API.

@zombieJ zombieJ merged commit 6f93146 into master Sep 17, 2025
7 of 10 checks passed
@zombieJ zombieJ deleted the nest-ignore branch September 17, 2025 07:28
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