Skip to content

Commit 7ea18a8

Browse files
authored
fix: notification onClose event runs repeatedly (#6150)
1 parent 5b3ade8 commit 7ea18a8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

components/vc-notification/Notice.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ export default defineComponent<NoticeProps>({
4646
] as any,
4747
setup(props, { attrs, slots }) {
4848
let closeTimer: any;
49-
const duration = computed(() => (props.duration === undefined ? 1.5 : props.duration));
49+
let isUnMounted = false;
50+
const duration = computed(() => (props.duration === undefined ? 4.5 : props.duration));
5051
const startCloseTimer = () => {
51-
if (duration.value) {
52+
if (duration.value && !isUnMounted) {
5253
closeTimer = setTimeout(() => {
5354
close();
5455
}, duration.value * 1000);
@@ -79,6 +80,7 @@ export default defineComponent<NoticeProps>({
7980
startCloseTimer();
8081
});
8182
onUnmounted(() => {
83+
isUnMounted = true;
8284
clearCloseTimer();
8385
});
8486

0 commit comments

Comments
 (0)