Skip to content

Commit 3183cec

Browse files
committed
fix: do proper cleanup
1 parent 4668260 commit 3183cec

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/components/terminal/terminalManager.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,22 +392,31 @@ class TerminalManager {
392392
async setupTerminalHandlers(terminalFile, terminalComponent, terminalId) {
393393
const textarea = terminalComponent.terminal?.textarea;
394394
if (textarea) {
395-
textarea.addEventListener("focus", () => {
395+
const onFocus = () => {
396396
const { $toggler } = quickTools;
397397
$toggler.classList.add("hide");
398398
clearTimeout(this.togglerTimeout);
399399
this.togglerTimeout = setTimeout(() => {
400400
$toggler.style.display = "none";
401401
}, 300);
402-
});
403-
textarea.addEventListener("blur", () => {
402+
};
403+
404+
const onBlur = () => {
404405
const { $toggler } = quickTools;
405406
clearTimeout(this.togglerTimeout);
406407
$toggler.style.display = "";
407408
setTimeout(() => {
408409
$toggler.classList.remove("hide");
409410
}, 10);
410-
});
411+
};
412+
413+
textarea.addEventListener("focus", onFocus);
414+
textarea.addEventListener("blur", onBlur);
415+
416+
terminalComponent.cleanupFocusHandlers = () => {
417+
textarea.removeEventListener("focus", onFocus);
418+
textarea.removeEventListener("blur", onBlur);
419+
};
411420
}
412421

413422
// Handle tab focus/blur
@@ -603,6 +612,11 @@ class TerminalManager {
603612
terminal.file._resizeObserver.disconnect();
604613
}
605614

615+
// Cleanup focus handlers
616+
if (terminal.component.cleanupFocusHandlers) {
617+
terminal.component.cleanupFocusHandlers();
618+
}
619+
606620
// Dispose terminal component
607621
terminal.component.dispose();
608622

0 commit comments

Comments
 (0)