fix: dialog opened/closed event triggered incorrectly,fixed #4902 (#4908)

This commit is contained in:
Netfan
2024-11-17 20:55:19 +08:00
committed by GitHub
parent ec53bf8084
commit 1302092798

View File

@@ -48,11 +48,14 @@ const delegatedProps = computed(() => {
const forwarded = useForwardPropsEmits(delegatedProps, emits);
const contentRef = ref<InstanceType<typeof DialogContent> | null>(null);
function onAnimationEnd() {
if (props.open) {
emits('opened');
} else {
emits('closed');
function onAnimationEnd(event: AnimationEvent) {
// 只有在 contentRef 的动画结束时才触发 opened/closed 事件
if (event.target === contentRef.value?.$el) {
if (props.open) {
emits('opened');
} else {
emits('closed');
}
}
}
defineExpose({