mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-28 19:30:30 +00:00
Fix logs view existing multiple times (#1000)
* Fix terminal DOM existing multiple times When switching between the tasks/config/changed files tabs in the build view, the DOM for the log xterm would be inserted multiple times, causing the current terminal to be shifted down weirdly. This fixes this behavior by cleaning any custom DOM before the log is unmounted. * Use ref
This commit is contained in:
parent
716d55a370
commit
3f73d5bf53
1 changed files with 11 additions and 0 deletions
|
@ -167,11 +167,16 @@ export default defineComponent({
|
|||
fitAddon.value.fit();
|
||||
}
|
||||
|
||||
const unmounted = ref(false);
|
||||
onMounted(async () => {
|
||||
term.value.loadAddon(fitAddon.value);
|
||||
term.value.loadAddon(new WebLinksAddon());
|
||||
|
||||
await nextTick(() => {
|
||||
if (unmounted.value) {
|
||||
// need to check if unmounted already because we are async here
|
||||
return;
|
||||
}
|
||||
const element = document.getElementById('terminal');
|
||||
if (element === null) {
|
||||
throw new Error('Unexpected: "terminal" should be provided at this place');
|
||||
|
@ -214,9 +219,15 @@ export default defineComponent({
|
|||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
unmounted.value = true;
|
||||
if (stream.value) {
|
||||
stream.value.close();
|
||||
}
|
||||
const element = document.getElementById('terminal');
|
||||
if (element !== null) {
|
||||
// Clean up any custom DOM added in onMounted above
|
||||
element.innerHTML = '';
|
||||
}
|
||||
window.removeEventListener('resize', resize);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue