From 1d793c90548cfecb70b5cec8b43029726fba1ca4 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 29 Dec 2025 04:58:12 -0800 Subject: [PATCH] Fix fit using correct dims on demo This doesn't add the debounce suggested in the issue, but it does comment about it. Fixes #4114 --- demo/client/client.ts | 6 ++++++ demo/index.css | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/demo/client/client.ts b/demo/client/client.ts index e484d8ca..69913984 100644 --- a/demo/client/client.ts +++ b/demo/client/client.ts @@ -340,11 +340,17 @@ function createTerminal(): Terminal { const resizeObserver = new ResizeObserver(entries => { if (optionsWindow.autoResize) { + // In general this should be debounced to avoid excessive work on the main + // thread by firing the expensive resize action repeatedly addons.fit.instance.fit(); } }); resizeObserver.observe(terminalContainer); + window.addEventListener('resize', () => { + terminalContainer.style.width = document.body.clientWidth + 'px'; + }); + // fit is called within a setTimeout, cols and rows need this. setTimeout(async () => { optionsWindow.initOptions(addDomListener); diff --git a/demo/index.css b/demo/index.css index 48a7a555..b3123eb2 100644 --- a/demo/index.css +++ b/demo/index.css @@ -7,6 +7,7 @@ body { height: 100vh; display: grid; grid-template-rows: 24px 1fr; + overflow: hidden; } #banner { @@ -41,11 +42,6 @@ body { color: #fff; } -#terminal-container { - height: 60%; - margin: 0 auto; -} - p { font-size: 0.9em; font-style: italic