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

pull/48/MERGE
Netfan 2024-11-17 20:55:19 +08:00 committed by GitHub
parent ec53bf8084
commit 1302092798
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 5 deletions

View File

@ -48,13 +48,16 @@ const delegatedProps = computed(() => {
const forwarded = useForwardPropsEmits(delegatedProps, emits); const forwarded = useForwardPropsEmits(delegatedProps, emits);
const contentRef = ref<InstanceType<typeof DialogContent> | null>(null); const contentRef = ref<InstanceType<typeof DialogContent> | null>(null);
function onAnimationEnd() { function onAnimationEnd(event: AnimationEvent) {
// contentRef opened/closed
if (event.target === contentRef.value?.$el) {
if (props.open) { if (props.open) {
emits('opened'); emits('opened');
} else { } else {
emits('closed'); emits('closed');
} }
} }
}
defineExpose({ defineExpose({
getContentRef: () => contentRef.value, getContentRef: () => contentRef.value,
}); });