Skip to content

Commit f77ab60

Browse files
committed
fix: clean up editor initialization when component unmounts early
1 parent 307af6d commit f77ab60

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

frontend/src/components/CodeViewer/index.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,13 @@ watch(
125125
},
126126
)
127127
128-
onMounted(() => setTimeout(() => initEditor(), inject(IS_IN_MODAL, false) ? 100 : 0))
129-
onUnmounted(() => (editorView || mergeView).destroy())
128+
let timer: number
129+
onMounted(() => (timer = setTimeout(() => initEditor(), inject(IS_IN_MODAL, false) ? 100 : 0)))
130+
onUnmounted(() => {
131+
clearTimeout(timer)
132+
const view = editorView || mergeView
133+
view?.destroy()
134+
})
130135
131136
const initEditor = () => {
132137
domRef.value!.innerHTML = ''

0 commit comments

Comments
 (0)