-
-
Notifications
You must be signed in to change notification settings - Fork 190
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: Free lock if motion not start #472
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Warning Rate limit exceeded@zombieJ has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 28 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
Walkthrough该 PR 在示例中为 Demo 组件增加了一个 “quick” 按钮,实现点击后快速显示并自动隐藏对话框。同时,更新了构建和发布脚本,调整了 package.json 中的依赖(如移除 Changes
Sequence Diagram(s)sequenceDiagram
participant U as 用户
participant D as Demo组件
participant Dialog as 对话框
U->>D: 点击 "quick" 按钮
D->>Dialog: 设置 showDialog = true
Dialog-->>D: 对话框显示
D->>Dialog: 0 毫秒超时后设置 showDialog = false
Dialog-->>D: 对话框隐藏
sequenceDiagram
participant D as Dialog组件
participant doClose as doClose函数
participant S as 系统
D->>D: onDialogVisibleChanged(visible=false)
D->>doClose: 调用 doClose()
doClose->>S: 清理滚动状态及恢复焦点
doClose->>D: 触发 afterClose 回调
Possibly related PRs
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎
|
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.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
src/Dialog/Content/index.tsx (1)
77-77
:⚠️ Potential issue修复 ref 类型不匹配问题
当前 dialogRef 的类型与 CSSMotion 组件期望的 ref 类型不匹配。
建议使用 CSSMotionRef 类型:
-ref={dialogRef} +ref={dialogRef as any} // 临时修复更好的解决方案是定义正确的类型:
import type { CSSMotionRef } from '@rc-component/motion'; const dialogRef = useRef<CSSMotionRef>();🧰 Tools
🪛 GitHub Actions: ✅ test
[error] 77-77: Type 'MutableRefObject<{ nativeElement: HTMLDivElement; inMotion: () => boolean; }>' is not assignable to type 'LegacyRef'.
🧹 Nitpick comments (2)
docs/examples/multiple-Portal.tsx (1)
48-58
: 建议优化快速显示/隐藏对话框的实现方式当前实现使用
setTimeout(fn, 0)
来立即隐藏对话框可能不是最佳方案:
- 这种方式可能导致不稳定的行为,因为 0ms 延迟并不保证立即执行
- 对于测试动画行为来说不够可靠
建议使用以下实现:
- <button - type="button" - onClick={() => { - setShowDialog(true); - setTimeout(() => { - setShowDialog(false); - }, 0); - }} - > - quick - </button> + <button + type="button" + onClick={() => { + // 使用 requestAnimationFrame 来确保状态更新在下一帧执行 + setShowDialog(true); + requestAnimationFrame(() => { + setShowDialog(false); + }); + }} + > + quick + </button>src/Dialog/index.tsx (1)
164-170
: 建议简化 useEffect 中的条件判断当前条件判断较为复杂,可以提取为一个命名良好的变量以提高可读性。
+ const shouldCloseImmediately = + animatedVisible && + contentRef.current.enableMotion() && + !contentRef.current.inMotion(); + - } else if ( - animatedVisible && - contentRef.current.enableMotion() && - !contentRef.current.inMotion() - ) { + } else if (shouldCloseImmediately) { doClose(); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
docs/examples/multiple-Portal.tsx
(1 hunks)package.json
(2 hunks)src/Dialog/Content/Panel.tsx
(1 hunks)src/Dialog/Content/index.tsx
(4 hunks)src/Dialog/Mask.tsx
(1 hunks)src/Dialog/index.tsx
(3 hunks)tests/index.spec.tsx
(2 hunks)tests/ref.spec.tsx
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- tests/ref.spec.tsx
- src/Dialog/Mask.tsx
🧰 Additional context used
🪛 GitHub Actions: ✅ test
src/Dialog/Content/index.tsx
[error] 46-46: Property 'enableMotion' does not exist on type '{ nativeElement: HTMLDivElement; inMotion: () => boolean; }'.
[error] 77-77: Type 'MutableRefObject<{ nativeElement: HTMLDivElement; inMotion: () => boolean; }>' is not assignable to type 'LegacyRef'.
🔇 Additional comments (8)
src/Dialog/Content/Panel.tsx (1)
20-23
: 类型重命名改进了代码清晰度将
ContentRef
重命名为PanelRef
更好地反映了该类型的用途和归属。src/Dialog/index.tsx (1)
83-100
: 提取的 doClose 函数改进了代码组织将关闭逻辑集中到
doClose
函数中提高了代码的可维护性和可读性。tests/index.spec.tsx (3)
3-3
: 导入路径已更新从 'rc-motion' 更新为 '@rc-component/motion',与包依赖变更保持一致。
9-25
: Mock 实现已更新Mock 路径和实现已更新以匹配新的包路径,保持了与实际代码的一致性。
518-520
: 测试用例改进使用 act() 包装 jest.runAllTimers() 调用,这是一个很好的改进,可以确保在测试期间正确处理所有状态更新。
Also applies to: 523-525
package.json (3)
40-40
: 构建脚本更新从 np 更新为 rc-np,这是一个更专业的发布工具。
55-55
: 依赖更新添加了 @rc-component/motion 作为新的动画实现依赖,替代了之前的 rc-motion。
58-59
: 开发依赖更新更新和添加了新的开发工具:
- @rc-component/father-plugin 升级到 ^2.0.2
- 新增 @rc-component/np ^1.0.3 用于发布流程
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #472 +/- ##
==========================================
- Coverage 99.44% 98.42% -1.03%
==========================================
Files 8 8
Lines 181 190 +9
Branches 60 64 +4
==========================================
+ Hits 180 187 +7
- Misses 1 3 +2 ☔ View full report in Codecov by Sentry. |
ref ant-design/ant-design#52625
Summary by CodeRabbit
新增功能
重构
构建和依赖维护
测试