Skip to content

Commit

Permalink
fix popover close immediately after opening
Browse files Browse the repository at this point in the history
  • Loading branch information
gene9831 committed Feb 17, 2025
1 parent 0d16d91 commit 486a763
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/canvas/container/src/components/CanvasViewerSwitcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:disabled="state.disabled"
popper-class="preview-switcher-popover"
ref="popoverRef"
:key="key"
>
<template #reference>
<div
Expand Down Expand Up @@ -92,6 +93,7 @@ export default {
)
const popoverRef = ref()
const key = ref(0)
const handleClick = async () => {
if (state.disabled) {
Expand All @@ -108,6 +110,13 @@ export default {
icon: 'text-page-common'
}))
)
// 重新渲染popover。如果不重新渲染popover,在popover已经弹出的情况下,再去另一个位置点击触发弹出,会导致popover闪现(打开后立即关闭)
key.value++
setTimeout(() => {
popoverRef.value?.doShow()
}, 0)
}
const handleSwitchPreview = (previewId) => {
Expand Down Expand Up @@ -146,6 +155,7 @@ export default {
return {
popoverRef,
state,
key,
handleClick,
handleSwitchPreview
}
Expand Down

0 comments on commit 486a763

Please sign in to comment.