From 6f24e55eae041ac55325f6724d4ca4089cd3ce65 Mon Sep 17 00:00:00 2001 From: 1zumii <524123601@qq.com> Date: Tue, 26 Mar 2024 10:31:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(Popper):=20=E4=BF=AE=E5=A4=8D=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=20trigger=20=E4=B8=8D=E5=8F=AF=E8=A7=81=E7=AB=8B=E5=8D=B3?= =?UTF-8?q?=E9=9A=90=E8=97=8F=20Popper(#701)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/popper/usePopper.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/popper/usePopper.ts b/components/popper/usePopper.ts index 65970544..97c65255 100644 --- a/components/popper/usePopper.ts +++ b/components/popper/usePopper.ts @@ -9,7 +9,6 @@ import { } from 'vue'; import { computePosition, offset, shift, flip, arrow } from '@floating-ui/dom'; import { isBoolean, isFunction } from 'lodash-es'; -import { useIntersectionObserver } from '@vueuse/core'; import { useNormalModel } from '../_util/use/useModel'; import popupManager from '../_util/popupManager'; import getElementFromVueInstance from '../_util/getElementFromVueInstance'; @@ -43,13 +42,6 @@ export default (props: PopperProps, emit: any) => { }`; }); - // 若触发元素已经被移除或隐藏,则关闭提示信息,否则会导致动画执行异常 - useIntersectionObserver(triggerRef, ([{ isIntersecting }]) => { - if (!isIntersecting) { - updateVisible(false); - } - }); - const computePopper = () => { if (isBoolean(props.disabled) && props.disabled) return; if (isFunction(props.disabled) && props.disabled()) return; @@ -73,6 +65,14 @@ export default (props: PopperProps, emit: any) => { ), } : getElementFromVueInstance(triggerRef.value); + + const triggerRect = triggerEl.getBoundingClientRect(); + // trigger 不可见的时候立即隐藏,允许误差 + if (triggerRect.width <= 1 && triggerRect.height <= 1) { + updateVisible(false); + return; + } + const popperEl = popperRef.value; computePosition(triggerEl, popperEl, { placement: props.placement,