-
-
Notifications
You must be signed in to change notification settings - Fork 167
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: 🐛 修复DropMenu第一次通过open()而非用户点击打开时展开菜单定位错误问题 #671
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough该拉取请求对 Changes
Possibly related PRs
Suggested reviewers
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 (
|
✅ Deploy Preview for wot-design-uni ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- src/uni_modules/wot-design-uni/components/wd-drop-menu/wd-drop-menu.vue (3 hunks)
🧰 Additional context used
🔇 Additional comments (1)
src/uni_modules/wot-design-uni/components/wd-drop-menu/wd-drop-menu.vue (1)
109-118
: 确认updateOffset
函数的健壮性
updateOffset
函数中使用了getRect
获取元素的位置信息,并根据方向计算offset
的值。请确保在可能的情况下,rect
始终能正确获取,否则可能导致offset
未被更新,影响菜单的定位。建议在全局搜索可能影响
dropMenuId
和proxy
的代码,确保在任何情况下getRect
都能返回有效的rect
。
onMounted(() => { | ||
updateOffset() | ||
}) |
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.
建议在 onMounted
中正确处理异步函数
在 onMounted
钩子中调用了异步函数 updateOffset()
,但未使用 await
等待其完成。这可能导致在组件挂载后,offset
尚未更新就进行后续操作。建议将 onMounted
改为异步函数,并使用 await
确保 updateOffset()
完成。
建议修改如下:
-onMounted(() => {
+onMounted(async () => {
await updateOffset()
})
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
onMounted(() => { | |
updateOffset() | |
}) | |
onMounted(async () => { | |
await updateOffset() | |
}) |
async function fold(child: any) { | ||
await updateOffset() | ||
child.$.exposed!.toggle() |
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.
注意异步函数调用的返回值处理
fold
函数已被修改为异步函数,但在 toggle
函数中调用时未处理返回的 Promise。这可能导致在 updateOffset()
未完成时就执行了后续的 toggle()
操作,可能引发逻辑问题。建议在调用 fold(child)
时适当处理异步。
如果需要等待 fold
完成,建议修改 toggle
函数:
function toggle(child: any) {
// 点击当前菜单,关闭其他菜单
if (child && !child.disabled) {
if (queue && queue.closeOther) {
queue.closeOther(child)
} else {
closeOther(child)
}
- fold(child)
+ fold(child)
+ .then(() => {
+ // 后续操作
+ })
+ .catch((error) => {
+ console.error(error)
+ })
}
}
或者将 toggle
函数也修改为异步函数:
- function toggle(child: any) {
+ async function toggle(child: any) {
// 点击当前菜单,关闭其他菜单
if (child && !child.disabled) {
if (queue && queue.closeOther) {
queue.closeOther(child)
} else {
closeOther(child)
}
- fold(child)
+ await fold(child)
}
}
请根据具体需求选择合适的修改方式。
Committable suggestion was skipped due to low confidence.
🤔 这个 PR 的性质是?(至少选择一个)
🔗 相关 Issue
💡 需求背景和解决方案
☑️ 请求合并前的自查清单
Summary by CodeRabbit
新功能
改进