fix(design): popover zindex不生效

This commit is contained in:
roymondchen 2024-08-15 16:11:36 +08:00 committed by roymondchen
parent d4408aaa32
commit e53c0e1ce5

View File

@ -39,8 +39,6 @@ const props = withDefaults(defineProps<PopoverProps>(), {
visible: undefined,
});
const zIndex = useZIndex();
const curZIndex = ref<number>(2);
const popoverVisible = ref(false);
const visibleWatch = watch(
@ -85,11 +83,12 @@ onMounted(() => {
referenceElementRef.value = getCurrentInstance()?.proxy?.$el.nextElementSibling;
});
const zIndex = useZIndex();
watch([referenceElementRef, popperElementRef], ([referenceElement, popperElement]) => {
destroy();
if (!referenceElement || !popperElement) return;
popperElement.style.zIndex = `${curZIndex.value}`;
popperElement.style.zIndex = `${zIndex.nextZIndex()}`;
popperElement.focus();
instanceRef.value = createPopper(referenceElement, popperElement, {
@ -132,7 +131,7 @@ const mouseleaveHandler = () => {
timer = setTimeout(() => {
popoverVisible.value = false;
}, 300);
}, 500);
};
if (props.trigger === 'click' && typeof props.visible === 'undefined') {
@ -170,21 +169,6 @@ if (props.trigger === 'hover' && typeof props.visible === 'undefined') {
});
}
watch(
popoverVisible,
(popoverVisible) => {
if (!popoverVisible) {
return;
}
nextTick().then(() => {
curZIndex.value = zIndex.nextZIndex();
});
},
{
immediate: true,
},
);
const destroy = () => {
if (!instanceRef.value) return;