-
Notifications
You must be signed in to change notification settings - Fork 356
refactor(Dialog): optimize Dialog and Portal #3705
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
base: develop
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR optimizes the Dialog and Portal components to address rendering issues where child elements calculating values in useLayoutEffect or useEffect could cause exceptions. The solution delays rendering children in Portal until after useEffect execution.
- Refactors Portal to use state-controlled mounting instead of immediate rendering
- Optimizes Dialog animation and positioning logic with improved state management
- Removes autofocus call from Textarea useEffect
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
packages/components/common/Portal.tsx | Implements delayed mounting pattern with state control to prevent child rendering issues |
packages/components/dialog/Dialog.tsx | Adds animation state management and mouse position tracking for better dialog positioning |
packages/components/textarea/Textarea.tsx | Removes handleAutoFocus call from useEffect dependency array |
commit: |
🤔 这个 PR 的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
优化 Dialog 或 Portal 执行渲染时,子元素一些在 useLayoutEffect 或 useEffect 时,一些计算值时导致的异常问题;
在 Portal 的 useEffect 之后才渲染 children ;
📝 更新日志
refactor(Dialog): 优化
Dialog
和 Portal 的渲染阶段本条 PR 不需要纳入 Changelog
☑️ 请求合并前的自查清单