diff --git a/src/components/terminal/terminalManager.js b/src/components/terminal/terminalManager.js index 5f2d0d1ce..f9d22dd2d 100644 --- a/src/components/terminal/terminalManager.js +++ b/src/components/terminal/terminalManager.js @@ -668,8 +668,9 @@ class TerminalManager { const RESIZE_DEBOUNCE = 200; let lastResizeTime = 0; - let lastWidth = 0; - let lastHeight = 0; + let lastWidth = null; + let lastHeight = null; + const handleResize = (entries) => { const now = Date.now(); const entry = entries && entries[0]; @@ -677,6 +678,21 @@ class TerminalManager { const width = cr?.width ?? terminalFile.content?.clientWidth ?? 0; const height = cr?.height ?? terminalFile.content?.clientHeight ?? 0; + // Skip resize events when container is hidden (via any method: inline style, CSS class, etc.) + const isHidden = + getComputedStyle(terminalFile.content).display === "none" || + terminalFile.content?.offsetHeight === 0; + if (isHidden) { + return; + } + + if (lastWidth === null || lastHeight === null) { + lastWidth = width; + lastHeight = height; + + return; + } + // Clear any pending resize if (resizeTimeout) { clearTimeout(resizeTimeout);